Skip to content

fix(cli): resolve team ID from env var, avoid config mismatch#1121

Merged
tomassrnka merged 1 commit intomainfrom
2026-02-08-team-id-cli-fix
Feb 9, 2026
Merged

fix(cli): resolve team ID from env var, avoid config mismatch#1121
tomassrnka merged 1 commit intomainfrom
2026-02-08-team-id-cli-fix

Conversation

@tomassrnka
Copy link
Copy Markdown
Member

@tomassrnka tomassrnka commented Feb 9, 2026

Summary

  • When E2B_API_KEY is set via environment variable, the CLI no longer falls back to the teamId from
    ~/.e2b/config.json, avoiding "Team ID param mismatch with the API key" errors
  • Adds E2B_TEAM_ID environment variable support
  • Introduces resolveTeamId() helper with clear precedence: --team CLI flag > E2B_TEAM_ID env var > config
    file (only when E2B_API_KEY env var is not set)

Problem

When using E2B_API_KEY env var (e.g. for local development or CI with a different team), the CLI still
reads teamId from ~/.e2b/config.json and sends it as a query parameter. If the config file belongs to a
different team than the API key, the API rejects the request with 400: Team ID param mismatch with the
API key.

Changes

  • api.ts: Export E2B_TEAM_ID env var, add resolveTeamId() helper
  • list.ts, build.ts, delete.ts, publish.ts: Use resolveTeamId() instead of inline userConfig?.teamId
    fallback

Test plan

  • Set E2B_API_KEY to a key from team A, have ~/.e2b/config.json with team B's ID → e2b template list
    should work (no mismatch error)
  • Set both E2B_API_KEY and E2B_TEAM_ID → CLI uses the env var team ID
  • Without any env vars, normal e2b auth login flow still works as before
  • --team flag still takes highest priority

Note

Low Risk
Small, localized change to CLI argument/env/config precedence for team selection; main risk is behavior changes for users relying on implicit ~/.e2b/config.json teamId when also setting E2B_API_KEY.

Overview
Fixes sandbox template commands failing with "Team ID param mismatch" when E2B_API_KEY is set via environment by changing team resolution precedence and avoiding ~/.e2b/config.json team fallback in that case.

Introduces E2B_TEAM_ID and a centralized resolveTeamId() helper (CLI flag > env var > local e2b.toml > user config only when no env API key), and updates template build, list, delete, and publish flows to use it consistently. Adds a changeset bump for @e2b/cli.

Written by Cursor Bugbot for commit 905172f. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 9, 2026

🦋 Changeset detected

Latest commit: 905172f

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

This PR includes changesets to release 1 package
Name Type
@e2b/cli 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

@tomassrnka tomassrnka force-pushed the 2026-02-08-team-id-cli-fix branch 2 times, most recently from 43bf51a to 7979d3f Compare February 9, 2026 05:19
@tomassrnka tomassrnka marked this pull request as ready for review February 9, 2026 15:51
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a774616256

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/cli/src/commands/template/build.ts Outdated
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread packages/cli/src/commands/template/build.ts Outdated
@tomassrnka tomassrnka force-pushed the 2026-02-08-team-id-cli-fix branch from a774616 to 2c42ae9 Compare February 9, 2026 16:01
When E2B_API_KEY is set via environment variable, the CLI was still
reading teamId from ~/.e2b/config.json, causing "Team ID param mismatch"
errors when the config file belonged to a different team.

Add E2B_TEAM_ID env var support and a resolveTeamId() helper with
proper precedence: CLI --team flag > E2B_TEAM_ID env var > config file
(config file team ID is only used when E2B_API_KEY env var is NOT set).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tomassrnka tomassrnka force-pushed the 2026-02-08-team-id-cli-fix branch from 2c42ae9 to 905172f Compare February 9, 2026 16:09
@tomassrnka tomassrnka merged commit 575d5bc into main Feb 9, 2026
16 of 18 checks passed
@tomassrnka tomassrnka deleted the 2026-02-08-team-id-cli-fix branch February 9, 2026 17:46
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.

2 participants