Repository navigation
fix(drive): download the target of a shortcut - #1315
saariuslystoned wants to merge 2 commits into
Conversation
drive download treated every application/vnd.google-apps.* type as a Workspace document, so a shortcut ID went to files.export, which only exports Docs Editors files. Read shortcutDetails.targetId and download or export the target instead. An unreadable target keeps Drive's error, so a deleted target still exits not_found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesResolve Drive shortcuts to their targets before downloading files or exporting Workspace documents. Example: Run gog drive download sc1 when shortcut sc1 points to t1, named report.pdf.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main download failure and remains worth merging; the earlier changelog finding is resolved, with no actionable code defects found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Drive download command receives a file ID and output options, reads metadata through the account's Drive service, and sends the resolved file to the existing export or media downloader. flowchart TD
A[Drive download command] --> B[Read file metadata]
B --> C[Resolve shortcut target]
B --> D[Existing download pipeline]
C --> D
D --> E[Drive media or export request]
E --> F[Output file or stdout]
Technical reviewBest possible solution: Merge the focused target-resolution fix while retaining the existing downloader and overwrite safeguards. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows shortcut IDs reaching files.export, supported by the contributor's before-and-after CLI trace; no target code was run during this read-only review. Is this the best way to solve the issue? Resolving metadata once before the existing download pipeline is a small, complete fix for accessible file targets, without duplicating transfer or output logic. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e8428c36dd31. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 8, 2026, 2:19 PM ET / 19:19 UTC (Revision 2). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thank you for the fix. I reproduced the claim and consolidated downloading or exporting the Drive shortcut target into #1336, with regression coverage and your coauthor credit retained. The full |
What problem this solves
A Drive shortcut (
application/vnd.google-apps.shortcut) is a metadata-only file. The Drive shortcuts guide describes it as a link holdingshortcutDetails.targetId, with its own title, and that title can differ from the target's.gog drive lsanddrive searchlist shortcuts beside regular files, sogog drive download <id>on a listed item often gets a shortcut ID.drive downloadtreats everyapplication/vnd.google-apps.*MIME type as a Workspace document. For a shortcut it therefore callsfiles.exporton the shortcut itself withapplication/pdf. A shortcut has no content to export, so the download fails instead of fetching the file the shortcut points to.Change
drive downloadnow also requestsshortcutDetails(targetId)in its metadata call. When the file is a shortcut, it reads the target'sid, name, mimeTypeand continues with the target. A blob target is downloaded withalt=media, and a Docs Editors target is exported, including--format. A file name chosen by gog comes from the target (<targetId>_<name>), so it carries the real extension.If the target can't be read (deleted, or no longer shared), the error names both IDs and wraps Drive's error. A deleted target still exits
not_found(5).Other files and
--tabexports are unchanged. A shortcut to a folder still fails as before, now on the folder.Evidence
internal/cmd/drive_download_shortcut_test.godrivesDriveDownloadCmdwith Drive metadata from anhttptestserver and recorded download/export calls. It covers:alt=mediadownload of the targetAll three fail on
main(e8428c3) because gog exports the shortcut ID, and pass with this change. The existing Drive download and get tests pass.A built
bin/gogfrommainand from this branch was run against a local Drive stand-in throughGOG_GOOGLE_API_BASE_URL, with an emptyGOG_HOMEand the file keyring. The stand-in is not Google. It servessc1as a shortcut tot1(report.pdf) and answers an export of anything that isn't a Docs file with a 403 in its own wording:make cipassed locally (macOS arm64, go1.27.3).Boundary: no live Google Drive was used, and the exact error Drive returns for exporting a shortcut was not captured.
targetResourceKeyis not forwarded.drive downloadsends no resource keys for any file today, so a link-shared target that needs one behaves as it would if downloaded by its own ID.🤖 Generated with Claude Code