Skip to content

fix(google): shared-drive params on Drive v3 proxy (Bug 2)#251

Open
chitcommit wants to merge 1 commit into
mainfrom
fix/gdrive-shared-drive-params
Open

fix(google): shared-drive params on Drive v3 proxy (Bug 2)#251
chitcommit wants to merge 1 commit into
mainfrom
fix/gdrive-shared-drive-params

Conversation

@chitcommit

Copy link
Copy Markdown
Contributor

Bug 2 — Drive proxy omits shared-drive params

The Google Drive proxy (src/api/routes/google.js) never set supportsAllDrives=true on any Drive v3 get/export/download call, nor the shared-drive corpora params on list. Files living in a shared drive therefore 404 even with a valid delegated token whose impersonated user is a member of that drive.

Changes

  • GET /gdrive/files (list): supportsAllDrives=true, includeItemsFromAllDrives=true, corpora=allDrives
  • GET /gdrive/files/:fileId (metadata): supportsAllDrives=true
  • GET /gdrive/files/:fileId/content: supportsAllDrives=true on the metadata pre-fetch, the Google-native export URL, and the alt=media download URL

The content route fetches metadata first, so the metadata 404 is what broke the entire download flow.

Verification (ground truth)

File 1pfPB3gq_l2LUWW29k3hadCi0q5F507-i — a 1.84 MB PDF in the "Arias V Bianchi" shared drive (driveId 0AHH7mqSeNtbbUk9PVA). Fetched directly against the Drive v3 API with a delegated service-account token (sub=nick@jeanarlene.com, scope drive), mirroring the prod rotation path exactly:

Call Result
files.get?fields=mimeType (no param) 404 File not found
files.get?fields=mimeType&supportsAllDrives=true 200
files.get?alt=media&supportsAllDrives=true (content) 200 + 1,844,037 bytes
files.list with shared-drive corpora params 200 (lists shared-drive contents)

GAM fetches the same file as ground truth, confirming the delegated subject is a member of the shared drive.

Deploy gate

Do NOT auto-merge. Operator approves prod deploys of new code. This PR is the code half of the shared-drive fix; the credential half (Bug 1, augmented SA JSON in CREDENTIAL_CACHE KV) has already been provisioned out-of-band.

🤖 Generated with Claude Code

The Google Drive proxy omitted `supportsAllDrives` on all file get/export/
download calls and the shared-drive corpora params on list, so files living
in a shared drive 404'd even with a valid delegated token whose impersonated
user is a member of that drive.

Changes (src/api/routes/google.js):
- GET /gdrive/files (list): add supportsAllDrives=true,
  includeItemsFromAllDrives=true, corpora=allDrives
- GET /gdrive/files/:fileId (metadata): add supportsAllDrives=true
- GET /gdrive/files/:fileId/content: add supportsAllDrives=true to the
  metadata pre-fetch, the Google-native export URL, and the alt=media
  download URL

Proven against ground-truth file 1pfPB3gq_l2LUWW29k3hadCi0q5F507-i (1.84MB
PDF in the "Arias V Bianchi" shared drive, driveId 0AHH7mqSeNtbbUk9PVA),
fetched with a delegated SA token (sub=nick@jeanarlene.com, drive scope):

  files.get?fields=mimeType                        -> 404 File not found
  files.get?fields=mimeType&supportsAllDrives=true -> 200
  files.list (shared corpora params)               -> 200 (lists drive contents)

The content route fetches metadata FIRST, so the metadata 404 is what broke
the whole download flow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 14, 2026 11:27
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@chitcommit, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 11 minutes and 35 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a0ac79a0-a501-41fd-bfb5-203d5a77a14b

📥 Commits

Reviewing files that changed from the base of the PR and between c27eab2 and 585bee4.

📒 Files selected for processing (1)
  • src/api/routes/google.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gdrive-shared-drive-params

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
chittyconnect 585bee4 Jun 14 2026, 11:27 AM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Google Drive v3 proxy behavior for files stored in shared drives by ensuring the required shared-drive query parameters are included on list/get/download flows.

Changes:

  • Add shared-drive list parameters (supportsAllDrives, includeItemsFromAllDrives, corpora=allDrives) to GET /gdrive/files.
  • Add supportsAllDrives=true to GET /gdrive/files/:fileId metadata requests.
  • Add supportsAllDrives=true to the content route’s metadata prefetch and to both export and alt=media download URLs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/api/routes/google.js
Comment on lines +97 to +98
// Shared-drive support: without these, files living in shared drives are
// invisible to list/get even when the delegated user is a member.
Comment thread src/api/routes/google.js
Comment on lines +99 to +101
params.set("supportsAllDrives", "true");
params.set("includeItemsFromAllDrives", "true");
params.set("corpora", "allDrives");
Comment thread src/api/routes/google.js
Comment on lines +118 to +119
// Shared-drive support — required for files that live in a shared drive.
params.set("supportsAllDrives", "true");
Comment thread src/api/routes/google.js
Comment on lines +140 to 142
const metadataResponse = await fetch(`${DRIVE_API}/files/${encodedFileId}?fields=mimeType&supportsAllDrives=true`, {
headers: { Authorization: `Bearer ${token}` },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants