Skip to content

fix(cli): unify teamId scoping for all marketplace integration commands#15183

Merged
tonypan2 merged 1 commit intomainfrom
tonypan/unify-marketplace-teamid-scoping
Feb 21, 2026
Merged

fix(cli): unify teamId scoping for all marketplace integration commands#15183
tonypan2 merged 1 commit intomainfrom
tonypan/unify-marketplace-teamid-scoping

Conversation

@tonypan2
Copy link
Copy Markdown
Contributor

@tonypan2 tonypan2 commented Feb 20, 2026

Summary

For Northstar users, getScope() resolves the team via user.defaultTeamId but does not set client.config.currentTeam. This meant client.fetch() never auto-appended teamId, causing API calls to scope to the wrong context — returning empty results or 409 "already installed" errors.

Previously each utility tried to fix this independently by accepting explicit teamId params (e.g. #15054 for fetchMarketplaceIntegrations). This was whack-a-mole — other utilities like fetchInstallations, fetchInstallationPrepaymentInfo, and getResources had the same bug.

This PR unifies the pattern: every integration/integration-resource command now sets client.config.currentTeam = team.id after getScope(), matching the established pattern used by ~13 other CLI commands (env, flags, deploy, etc.). All downstream utilities rely on auto-append and no longer accept explicit teamId/team params.

Changes

9 commands — add currentTeam assignment after getScope:

  • integration add, integration add (auto-provision), integration balance
  • integration list, integration open, integration remove
  • integration-resource disconnect, integration-resource create-threshold, integration-resource remove

5 utilities — remove explicit teamId params:

Implicitly fixed utilities (already relied on auto-append, but currentTeam was never set for Northstar users before this PR):

  • fetchInstallations — called from add.ts and add-auto-provision.ts
  • disconnectResourceFromProject, provisionStoreResource, createAuthorization, fetchBillingPlans

Net effect: -31 lines, simpler utility signatures, one consistent pattern.

Test plan

Unit Tests

$ cd packages/cli && pnpm vitest run test/unit/commands/integration/add.test.ts test/unit/commands/integration/add-auto-provision.test.ts test/unit/commands/integration/balance.test.ts test/unit/util/integration/fetch-installation-prepayment-info.test.ts

 ✓ test/unit/util/integration/fetch-installation-prepayment-info.test.ts  (1 test)
 ✓ test/unit/commands/integration/balance.test.ts  (16 tests)
 ✓ test/unit/commands/integration/add.test.ts  (75 tests)
 ✓ test/unit/commands/integration/add-auto-provision.test.ts  (73 tests)

 Test Files  4 passed (4)
      Tests  165 passed (165)
  • Northstar fallback test in balance.test.ts validates teamId is present via auto-append
  • Mock useConfiguration validates teamId query param is present (400 if missing)

Manual Testing

All commands tested with --debug to verify teamId auto-injection in every API URL:

Command API endpoints hit teamId present Result
vc integration list /v1/storage/stores Listed resources correctly
vc integration balance upstash /v2/integrations/configurations, /v1/storage/stores, /v1/integrations/installations/.../billing/balance ✅ (all 3) Retrieved balance info
vc integration open upstash /v2/integrations/configurations Printed SSO URL with correct teamId
vc integration add upstash (legacy) /v2/integrations/integration/upstash, /v2/integrations/configurations ✅ (both) Reached product selection prompt
FF=1 vc integration add upstash/upstash-kv (auto-provision) /v2/integrations/integration/upstash, /v2/integrations/configurations ✅ (both) Reached wizard prompts
vc integration remove upstash /v2/integrations/configurations Confirmation prompt appeared
vc integration-resource disconnect /v1/storage/stores Reached resource lookup

Code paths covered

Utility function Old behavior New behavior Verified by
getResources() Manual teamId query param Auto-injected via currentTeam Manual (list, balance, disconnect) + unit
fetchMarketplaceIntegrations() Manual teamId + useCurrentTeam: false Auto-injected (removed opt-out) Manual (balance, open, remove, add) + unit
deleteResource() Manual teamId from team param Auto-injected Unit only (destructive)
removeIntegration() Manual teamId from team param Auto-injected Unit only (destructive)
fetchInstallationPrepaymentInfo() Manual teamId query param Auto-injected Manual (balance) + unit

🤖 Generated with Claude Code

Note

Low Risk Change

Refactors CLI commands to set currentTeam config after getScope() and removes explicit teamId parameters from utility functions, relying on auto-append behavior - a pattern change that could affect API scoping if currentTeam is not properly set.

  • Adds client.config.currentTeam = team.id assignment in 9 integration commands
  • Removes explicit teamId params from 5 utility functions (getResources, fetchMarketplaceIntegrations, etc.)
  • Removes useCurrentTeam: false flag from fetchMarketplaceIntegrations

Risk assessment for commit 7e1035f.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 20, 2026

🦋 Changeset detected

Latest commit: 7e1035f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 20, 2026

📦 CLI Tarball Ready

The Vercel CLI tarball for this PR is now available!

Quick Test

You can test this PR's CLI directly by running:

npx https://vercel-5bdyf1mcm.vercel.sh/tarballs/vercel.tgz --help

Use in vercel.json

To use this CLI version in your project builds, add to your vercel.json:

{
  "build": {
    "env": {
      "VERCEL_CLI_VERSION": "vercel@https://vercel-5bdyf1mcm.vercel.sh/tarballs/vercel.tgz"
    }
  }
}

Python Runtime Wheel

A Python runtime wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_RUNTIME_PYTHON="vercel-runtime @ https://vercel-5bdyf1mcm.vercel.sh/tarballs/vercel_runtime-0.6.0.dev1771620402+7e1035f-py3-none-any.whl"

@tonypan2 tonypan2 marked this pull request as ready for review February 20, 2026 17:51
@tonypan2 tonypan2 requested review from a team as code owners February 20, 2026 17:51
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 20, 2026

🧪 Unit Test Strategy

Comparing: d269bdc7e1035f (view diff)

Strategy: Affected packages only

✅ Only testing packages that have been modified or depend on modified packages.

Affected packages - 1 (3%)
  1. vercel
Unaffected packages - 39 (98%)
  1. @vercel-internals/get-package-json
  2. @vercel/backends
  3. @vercel/build-utils
  4. @vercel/cervel
  5. @vercel/cli-auth
  6. @vercel/client
  7. @vercel/config
  8. @vercel/detect-agent
  9. @vercel/edge
  10. @vercel/elysia
  11. @vercel/error-utils
  12. @vercel/express
  13. @vercel/fastify
  14. @vercel/firewall
  15. @vercel/frameworks
  16. @vercel/fs-detectors
  17. @vercel/functions
  18. @vercel/gatsby-plugin-vercel-builder
  19. @vercel/go
  20. @vercel/h3
  21. @vercel/hono
  22. @vercel/hydrogen
  23. @vercel/koa
  24. @vercel/nestjs
  25. @vercel/next
  26. @vercel/node
  27. @vercel/oidc
  28. @vercel/oidc-aws-credentials-provider
  29. @vercel/python
  30. @vercel/python-analysis
  31. @vercel/redwood
  32. @vercel/related-projects
  33. @vercel/remix-builder
  34. @vercel/routing-utils
  35. @vercel/ruby
  36. @vercel/rust
  37. @vercel/static-build
  38. @vercel/static-config
  39. examples

Results

  • Unit tests: Only affected packages will run unit tests
  • E2E tests: Running in parallel via E2E Tests workflow
  • Type checks: Only affected packages will run type checks

This comment is automatically generated based on the affected testing strategy

@bhrigu123
Copy link
Copy Markdown
Contributor

Nice cleanup — the unified client.config.currentTeam pattern is much better than per-utility teamId params.

One suggestion: consider adding a regression test that validates the actual Northstar path end-to-end — i.e., a mock client where currentTeam starts unset, getScope() returns a team, and the test asserts the downstream API call includes teamId via auto-append. The existing tests likely pass because the mock client already has currentTeam configured, so they wouldn't catch a regression where the client.config.currentTeam = team.id assignment gets accidentally removed.

Written by claude code on behalf of @bhrigu123

@tonypan2 tonypan2 force-pushed the tonypan/unify-marketplace-teamid-scoping branch from c6f6c86 to 416da2a Compare February 20, 2026 18:38
@tonypan2
Copy link
Copy Markdown
Contributor Author

Added a Northstar regression test in balance.test.ts — it starts with currentTeam unset, uses a northstar user with defaultTeamId, and the useConfiguration mock returns 400 if teamId is missing. This covers the path you described: getScope() resolves the team → client.config.currentTeam = team.id → downstream API calls include teamId via auto-append.

Also hardened the shared useConfiguration mock in integration.ts to validate teamId presence (matching the existing useResources behavior). Together with the existing test in remove.test.ts, two commands now have explicit Northstar coverage.

For Northstar users, `getScope()` resolves the team via
`user.defaultTeamId` but does not set `client.config.currentTeam`.
This meant `client.fetch()` never auto-appended `teamId`, causing
API calls to return empty results or 409 errors.

Previously each utility tried to fix this independently by accepting
explicit `teamId` params (e.g. PR #15054 for fetchMarketplaceIntegrations).
This was whack-a-mole — other utilities like fetchInstallations,
fetchInstallationPrepaymentInfo, and getResources had the same bug.

Unify the pattern: every integration/integration-resource command now
sets `client.config.currentTeam = team.id` after getScope(), matching
the established pattern used by ~13 other CLI commands (env, flags,
deploy, etc.). All downstream utilities rely on auto-append and no
longer accept explicit teamId/team params.

- 9 commands: add currentTeam assignment after getScope
- 5 utilities: remove explicit teamId params and searchParams
- All callers updated to match new signatures
- 276 tests pass across 10 test files
@tonypan2 tonypan2 force-pushed the tonypan/unify-marketplace-teamid-scoping branch from b84a803 to 7e1035f Compare February 20, 2026 20:46
@tonypan2 tonypan2 requested review from bhrigu123 and removed request for bhrigu123 February 20, 2026 22:11
@tonypan2 tonypan2 merged commit de8a6cd into main Feb 21, 2026
179 checks passed
@tonypan2 tonypan2 deleted the tonypan/unify-marketplace-teamid-scoping branch February 21, 2026 00:02
brookemosby pushed a commit that referenced this pull request Feb 23, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@13.5.0

### Minor Changes

- Add django experimental framework.
([#15196](#15196))

### Patch Changes

- Updated dependencies
\[[`cb79f6f8080fddd3673a8911566085e0265b060b`](cb79f6f)]:
    -   @vercel/python-analysis@0.7.0

## @vercel/frameworks@3.19.0

### Minor Changes

- Add django experimental framework.
([#15196](#15196))

## @vercel/python@6.16.0

### Minor Changes

- [python] add support for running generic ASGI/WSGI applications to vc
dev ([#15174](#15174))

### Patch Changes

- Updated dependencies
\[[`cb79f6f8080fddd3673a8911566085e0265b060b`](cb79f6f)]:
    -   @vercel/python-analysis@0.7.0

## @vercel/python-analysis@0.7.0

### Minor Changes

- Add django experimental framework.
([#15196](#15196))

## @vercel/backends@0.0.37

### Patch Changes

- Updated dependencies
\[[`cb79f6f8080fddd3673a8911566085e0265b060b`](cb79f6f)]:
    -   @vercel/build-utils@13.5.0

## @vercel/cervel@0.0.24

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/backends@0.0.37

## vercel@50.22.2

### Patch Changes

- fix(cli): add `integration-resource` command to `vc --help` output
([#15191](#15191))

- fix(cli): filter empty strings from trailing commas in array metadata
([#15163](#15163))

- fix(cli): add non-TTY guards and fix exit codes in marketplace
commands ([#15158](#15158))

- Adding in a non-interactive flag for env command
([#14912](#14912))

- fix(cli): unify teamId scoping for all marketplace integration
commands ([#15183](#15183))

- Updated dependencies
\[[`3c4aff4acbfa603705556d145236b8a9ef106331`](3c4aff4),
[`984d44875f959058f5d13fea27373785b1d66b6f`](984d448),
[`cb79f6f8080fddd3673a8911566085e0265b060b`](cb79f6f)]:
    -   @vercel/next@4.15.32
    -   @vercel/python@6.16.0
    -   @vercel/build-utils@13.5.0
    -   @vercel/backends@0.0.37
    -   @vercel/elysia@0.1.40
    -   @vercel/express@0.1.49
    -   @vercel/fastify@0.1.43
    -   @vercel/go@3.4.1
    -   @vercel/h3@0.1.49
    -   @vercel/hono@0.2.43
    -   @vercel/hydrogen@1.3.5
    -   @vercel/koa@0.1.23
    -   @vercel/nestjs@0.2.44
    -   @vercel/node@5.6.7
    -   @vercel/redwood@2.4.9
    -   @vercel/remix-builder@5.5.10
    -   @vercel/ruby@2.3.1
    -   @vercel/rust@1.0.5
    -   @vercel/static-build@2.8.41

## @vercel/client@17.2.46

### Patch Changes

- Updated dependencies
\[[`cb79f6f8080fddd3673a8911566085e0265b060b`](cb79f6f)]:
    -   @vercel/build-utils@13.5.0

## @vercel/elysia@0.1.40

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.7

## @vercel/express@0.1.49

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.7
    -   @vercel/cervel@0.0.24

## @vercel/fastify@0.1.43

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.7

## @vercel/fs-detectors@5.8.10

### Patch Changes

- Updated dependencies
\[[`cb79f6f8080fddd3673a8911566085e0265b060b`](cb79f6f)]:
    -   @vercel/frameworks@3.19.0

## @vercel/gatsby-plugin-vercel-builder@2.0.139

### Patch Changes

- Updated dependencies
\[[`cb79f6f8080fddd3673a8911566085e0265b060b`](cb79f6f)]:
    -   @vercel/build-utils@13.5.0

## @vercel/h3@0.1.49

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.7

## @vercel/hono@0.2.43

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.7

## @vercel/koa@0.1.23

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.7

## @vercel/nestjs@0.2.44

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.6.7

## @vercel/next@4.15.32

### Patch Changes

- Revert per function builder support
([#15209](#15209))

## @vercel/node@5.6.7

### Patch Changes

- Updated dependencies
\[[`cb79f6f8080fddd3673a8911566085e0265b060b`](cb79f6f)]:
    -   @vercel/build-utils@13.5.0

## @vercel/static-build@2.8.41

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.139

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants