fix(cloud-tests): unblock GCP picker when folder enumeration returns 403#2916
Merged
Merged
Conversation
…dden Customer Propper hit a real failure that PR #2899's folder enumeration could not handle. Verified in production CloudWatch logs: WARN [GCPSecurityService] Failed to list child folders of organizations/43356919874: { "error": { "code": 403, "message": "The caller does not have permission", "status": "PERMISSION_DENIED" } } LOG [GCPSecurityService] GCP detectProjectsForOrg(43356919874): 13 direct + 0 folder-nested → 13 unique Two coordinated changes: 1. Switch `cloudresourcemanager.googleapis.com/v2/folders` → `cloudresourcemanager.googleapis.com/v3/folders`. v2 is deprecated and was observed returning 403 PERMISSION_DENIED for OAuth grants that legitimately had org-level folder roles (roles/owner + roles/resourcemanager.folderAdmin). v3 is the current API and accepts the same `parent`/`pageSize`/`pageToken` query params, so the swap is purely defensive — response shape is identical. 2. Add a broad-query fallback in `listProjectsInOrgFolderTree`. When folder enumeration returns zero folder IDs (whether due to 403, 404, no folders existing, or anything else), retry with a broader `lifecycleState:ACTIVE AND parent.type:folder` query. That returns every folder-nested project the OAuth user can `projects.get`, which solves Greg's case without depending on the folders endpoint succeeding. Multi-org tradeoff: in a multi-org tenant the fallback path may include folder-nested projects from other orgs the user has access to. This is acceptable because: - the picker is selection-based — the user chooses what to monitor, - the alternative is a silently empty picker like Greg saw, - the user already authorized those projects via their IAM grant. When v3/folders works as expected, the precise per-folder query is preferred and the fallback never fires — verified by a new test that locks in this behavior. Tests: - 2 new regression tests on `gcp-security.service.spec.ts`: - customer-Propper scenario: v3/folders empty → broad fallback fires → folder-nested projects appear. - healthy multi-org scenario: v3/folders succeeds → precise scoping preserved, broad fallback does not fire. - All 15 GCP detection tests pass; full cloud-security suite (269 tests) passes; one pre-existing TLS env failure is unrelated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
3 tasks
Contributor
|
🎉 This PR is included in version 3.63.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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
Customer Propper (Greg) reported folder-nested GCP projects (
propperai-prod,propperai-demo) still didn't appear in the picker after PR #2899 shipped. Verified in production CloudWatch logs — GCP'scloudresourcemanager.googleapis.com/v2/foldersendpoint returns 403 PERMISSION_DENIED for his OAuth grant, despite the user holdingroles/owner+roles/resourcemanager.folderAdminat the org level. Folder enumeration silently returns[]→ picker has nothing folder-nested to show.Fix
Two coordinated changes:
v2/folders→v3/folders— v2 is deprecated and was observed returning 403 in production. v3 is the current API; same query params, same response shape, defensive swap.Broad-query fallback when enumeration returns 0 folders —
listProjectsInOrgFolderTreenow retries withlifecycleState:ACTIVE AND parent.type:folder(noparent.id). That returns every folder-nested project the OAuth user canprojects.get, regardless of whether we could enumerate the folder tree. Greg'spropperai-prodandpropperai-demoappear.Tradeoff (transparent)
In multi-org tenants (rare — most customers have a single org) the fallback may include folder-nested projects from other orgs the user has IAM access to. We're accepting this because:
When
v3/foldersworks as expected (the common case), the precise per-folder query is preferred and the fallback never fires. A new test locks in this behavior so the cubic P2 from PR #2899 stays satisfied for healthy tenants.Tests
gcp-security.service.spec.ts:v3/foldersempty → broad fallback fires → folder-nested projects appear.v3/folderssucceeds → precise scoping preserved, broad fallback does not fire.Manual test plan
propperai-prodandpropperai-demonow appear in the picker./ecs/comp-production-api, filter byGCP folder fallback for org— should appear after the deploy hits Greg's connection.v3/folderssucceeds does NOT trigger the fallback (log messageGCP folder fallbackshould not appear for them).🤖 Generated with Claude Code
Summary by cubic
Unblocks the GCP project picker when folder enumeration is forbidden. Switches to
v3/foldersand adds a broad fallback so folder-nested projects still show up.v2/folders→v3/foldersfor child folder listing.lifecycleState:ACTIVE AND parent.type:folder(noparent.id); in multi‑org tenants this may include projects from other orgs, which is acceptable for a selection-based picker.Written for commit 7fdc871. Summary will update on new commits. Review in cubic