fix(features): single source of truth for OAuth scopes; dedup read scopes (#323)#347
Open
allenhutchison wants to merge 3 commits intomainfrom
Open
fix(features): single source of truth for OAuth scopes; dedup read scopes (#323)#347allenhutchison wants to merge 3 commits intomainfrom
allenhutchison wants to merge 3 commits intomainfrom
Conversation
…opes when paired write enabled (#323) - `setup-gcp.sh` now sources scopes from `feature-config.ts` via a small `scripts/print-scopes.ts`, eliminating the hand-maintained list that drifted and caused users to hit "This app is blocked." - `resolveFeatures` skips a read group's scopes when its paired write group is enabled (the write scope grants read access at the API level). Avoids redundant `drive` + `drive.readonly` (etc.) consent prompts. - Drift-guard tests assert `print-scopes.ts` emits `getAllPossibleScopes()` and that `setup-gcp.sh` has no inlined scope list.
Contributor
There was a problem hiding this comment.
Code Review
This pull request centralizes OAuth scope management by dynamically generating the GCP consent screen registration list from the codebase, eliminating hardcoded values in setup-gcp.sh. It also introduces scope deduplication logic to avoid redundant permission prompts when write scopes are active. A review comment identifies a potential issue where environment warnings in the script output could be incorrectly parsed as scopes, suggesting a filter to only include valid URL strings.
execFileSync('npx', ...) fails on Windows because npx is npx.cmd and
Node's spawn doesn't auto-resolve .cmd extensions without a shell.
execSync runs through the shell on every platform.
Address review feedback: ts-node stderr (Node deprecation warnings, etc.) was captured into SCOPES_OUTPUT via 2>&1 and would have been surfaced to the user as bogus OAuth scopes. Filter on the https:// prefix instead, and fail loudly if filtering leaves zero scopes.
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.
Summary
setup-gcp.shnow sources its scope list fromfeature-config.tsvia a smallscripts/print-scopes.tsshim, replacing the hand-maintainedSCOPES=(...)array that drifted out of sync. This was the root cause in Published GCP project missing.readonlyscopes requested by default read feature groups #323 — the published GCP consent screen was missing the six.readonlyscopes thatfeature-config.tsrequests by default.resolveFeaturesno longer requests a<service>.readonlyscope when the paired<service>.writegroup is enabled (the write scope already grants read access at the API level). Avoids prompting users for bothdriveanddrive.readonly(etc.) on consent. Read tools are unaffected — only the redundant scope is dropped.print-scopes.tsemits exactlygetAllPossibleScopes(), and another assertssetup-gcp.shhas no inlined scope list.Note: the published
geminicli.comGCP project's consent screen was already updated out-of-band with the missing.readonlyscopes. This PR closes the code/script side so the gap can't recur.Test plan
npm run lintnpm run format:checknpm run buildnpm test— 484 passing (41 infeatures/, up from 22)npx ts-node --transpile-only scripts/print-scopes.tsoutputs the 17 expected scopes including the six.readonlyones.readonlyscopes requested by default read feature groups #323 (clearWORKSPACE_CLIENT_ID/WORKSPACE_CLOUD_FUNCTION_URL, OAuth on a non-test-user account) shows the consent screen instead of "This app is blocked"Closes #323