Skip to content

fix: smarter fallback team selection for scope inference#120

Merged
Schniz merged 13 commits intomainfrom
default-team
Apr 14, 2026
Merged

fix: smarter fallback team selection for scope inference#120
Schniz merged 13 commits intomainfrom
default-team

Conversation

@gr2m
Copy link
Copy Markdown
Contributor

@gr2m gr2m commented Mar 28, 2026

Summary

  • Fetches both /v2/user and /v2/teams in parallel to build an ordered list of candidate teams for scope inference
  • Tries user.defaultTeamId first, then falls back to the best hobby-plan OWNER team (personal team matching username, or most recently updated)
  • Filters fallback candidates by billing.plan === 'hobby' and membership.role === 'OWNER' to avoid selecting pro/enterprise teams
  • On 403, skips to the next candidate instead of failing immediately
  • Only throws after all candidates are exhausted, with a helpful error message including the authenticated username

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandbox Ready Ready Preview, Comment, Open in v0 Apr 14, 2026 8:11am
sandbox-cli Ready Ready Preview, Comment, Open in v0 Apr 14, 2026 8:11am
sandbox-sdk Ready Ready Preview, Comment, Open in v0 Apr 14, 2026 8:11am
sandbox-sdk-ai-example Ready Ready Preview, Comment, Open in v0 Apr 14, 2026 8:11am
workflow-code-runner Ready Ready Preview, Comment, Open in v0 Apr 14, 2026 8:11am

Instead of always falling back to the username, prefer the user's
configured default team (defaultTeamId). Falls back to username
when defaultTeamId is not set.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread packages/vercel-sandbox/src/auth/project.ts Outdated
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@marc-vercel marc-vercel left a comment

Choose a reason for hiding this comment

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

Overall LGTM, left 3 comments (two of them are optional).

I see that the tests mock the API response, but given that we are changing API requests/responses, have we manually tested all the flows? If possible I would love to have some integration tests, but because we are dealing with auth I do not think it will be easy.

Comment thread packages/vercel-sandbox/src/auth/project.ts
Comment thread packages/vercel-sandbox/src/auth/project.ts Outdated
Comment thread packages/vercel-sandbox/src/auth/project.ts
Comment thread packages/vercel-sandbox/src/auth/project.ts Outdated
Comment thread packages/vercel-sandbox/src/auth/project.ts
Comment thread .changeset/slick-lands-repeat.md
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.

4 participants