fix: Google Drive picks fail with 404 — call setAppId on Picker#2308
Merged
Conversation
With the drive.file OAuth scope (narrowest, picked-files-only), Google Picker only authorizes the picked file for our OAuth client when PickerBuilder.setAppId(<project_number>) is called. The hook from #2306 didn't set it, so every pick succeeded in the Picker UI but the server's download attempt hit "404 File not found" — surfacing as "Error handling Google Drive files" in the browser. The project number is the numeric prefix of the OAuth client ID (<project>-<hash>.apps.googleusercontent.com), so it's derived at runtime from REACT_APP_GOOGLE_CLIENT_ID rather than introducing a third env var. This eliminates the two-vars-can-drift footgun. Test mock updated with setAppId stub; added an assertion that confirms the derived project number is passed to setAppId. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Adds `.setAppId(projectNumber)` to the Picker builder chain in `useGooglePicker.ts`. `projectNumber` is derived at runtime from the existing `REACT_APP_GOOGLE_CLIENT_ID` (numeric prefix of the client ID), so no new env var is needed.
Why
With the `drive.file` OAuth scope (the narrowest, picked-files-only scope we chose in #2306), Google Picker only binds the picked file to our OAuth client when `setAppId` is called. Without it, the user can pick a file in the UI but the server's `GET https://www.googleapis.com/drive/v3/files/?alt=media` with the bearer token returns 404 File not found. Every Drive pick on prod was failing with "Error handling Google Drive files" until this fix.
Verified on prod logs:
```
2|server | google drive upload success
2|server | POST /api/upload/google_drive 400
...
status: 404, message: "File not found: 1Gxh9TSApii4ErELl0jePIGUVMldsgSRe"
```
How
Testing
Risks
Trio synthesis
Goal alignment
Closes the deploy-blocking bug from #2306 so the Drive tab actually works for the user base that needs it. Critical for the 300K-user goal — without this fix, the Drive tab is visible but every click fails.
Need help on this PR? Tag
@codesmithwith what you need.