refactor: Simplify Google Drive OAuth scopes management and add test for missing optional group scopes#1744
Conversation
…for missing optional group scopes
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
WalkthroughGoogleDriveOAuth now separates required Drive read scopes into a REQUIRED_SCOPES class attribute and reconstructs SCOPES by unpacking REQUIRED_SCOPES alongside OIDC profile scopes. Token validation now checks only REQUIRED_SCOPES. A unit test verifies credentials load when only required scopes exist. Minor TypeScript SDK tweaks included. ChangesGoogle Drive OAuth Scope Validation
TypeScript SDK tweaks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/connectors/google_drive/oauth.py (1)
21-33: 💤 Low valueConsider adding a docstring or comment to clarify the required vs. optional scope distinction.
The separation of
REQUIRED_SCOPESfrom the fullSCOPESlist is clear in structure, but a brief comment explaining that group/admin scopes are optional (for workspace features) while Drive scopes are required (for core connector functionality) would help future maintainers understand the design intent.📝 Suggested documentation addition
+ # Core Drive scopes required for all connector operations REQUIRED_SCOPES = [ "https://www.googleapis.com/auth/drive.readonly", "https://www.googleapis.com/auth/drive.metadata.readonly", ] + # Full scope list: OIDC + required Drive scopes + optional Workspace group scopes SCOPES = [ "openid", "email", "profile", *REQUIRED_SCOPES, + # Optional: group/admin scopes enable workspace group filtering but are not required "https://www.googleapis.com/auth/cloud-identity.groups.readonly", "https://www.googleapis.com/auth/admin.directory.group.readonly", ]🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/connectors/google_drive/oauth.py` around lines 21 - 33, Add a short docstring or inline comment above the REQUIRED_SCOPES and SCOPES definitions clarifying that REQUIRED_SCOPES (e.g., "https://www.googleapis.com/auth/drive.readonly", "https://www.googleapis.com/auth/drive.metadata.readonly") are mandatory for core Google Drive connector functionality, while the additional scopes included in SCOPES (the group/admin scopes such as "https://www.googleapis.com/auth/cloud-identity.groups.readonly" and "https://www.googleapis.com/auth/admin.directory.group.readonly") are optional and used only for workspace/group-related features; place this comment immediately above the REQUIRED_SCOPES/SCOPES symbols so future maintainers see the design intent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/connectors/google_drive/oauth.py`:
- Around line 21-33: Add a short docstring or inline comment above the
REQUIRED_SCOPES and SCOPES definitions clarifying that REQUIRED_SCOPES (e.g.,
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/drive.metadata.readonly") are mandatory for
core Google Drive connector functionality, while the additional scopes included
in SCOPES (the group/admin scopes such as
"https://www.googleapis.com/auth/cloud-identity.groups.readonly" and
"https://www.googleapis.com/auth/admin.directory.group.readonly") are optional
and used only for workspace/group-related features; place this comment
immediately above the REQUIRED_SCOPES/SCOPES symbols so future maintainers see
the design intent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8a4357e4-161b-42c4-94b5-b5400df7a257
📒 Files selected for processing (2)
src/connectors/google_drive/oauth.pytests/unit/test_oauth_encryption.py
…ease timeout for delete operation
Google Drive OAuth was requesting Drive scopes plus optional Google Workspace group/admin scopes, then treating all of them as required. If Google withheld either optional scope, the OAuth callback could succeed, but the next connector status check would reject/delete the token and show Google Drive as not connected. That matches your symptom: consent flow completes, but ingestion/file selection never becomes enabled.
Summary by CodeRabbit