Skip to content

Conversation

0div
Copy link
Contributor

@0div 0div commented Jul 7, 2025

Description

The team ID is derived from the provided access token for this specific command, this PR lets you still explicitly specify the team id via opts but does not take it from the user config to avoid unwanted team does not exist errors when specifying access tokens for different clusters.

Test

$ [E2B/packages/cli] pnpm build

# test while being logged in
$ [E2B/templates/base] e2b auth login # in prod
$ [E2B/templates/base] E2B_DOMAIN=<your_dev_domain> E2B_ACCESS_TOKEN=<your_access_token> ../../packages/cli/dist/index.js template build

# test while being logged in with no env vars
$ [E2B/templates/base] ../../packages/cli/dist/index.js template build

# test while being logged in with no env vars and team id flag
$ [E2B/templates/base] ../../packages/cli/dist/index.js template build --team
<your_prod_team_id>

# test while being looged in with team flag 
$ [E2B/templates/base] E2B_DOMAIN=<your_dev_domain> E2B_ACCESS_TOKEN=<your_access_token> ../../packages/cli/dist/index.js template build --team <your_dev_team_id> 

# test while being logged out 
$ [E2B/templates/base] e2b auth logout
$ [E2B/templates/base] E2B_DOMAIN=<your_dev_domain> E2B_ACCESS_TOKEN=<your_access_token> ../../packages/cli/dist/index.js template build

# test while being logged out and specifying team id
$ [E2B/templates/base] E2B_DOMAIN=<your_dev_domain> E2B_ACCESS_TOKEN=<your_access_token> ../../packages/cli/dist/index.js template build --team <your_dev_team_id> 

Copy link

linear bot commented Jul 7, 2025

Copy link

changeset-bot bot commented Jul 7, 2025

⚠️ No Changeset found

Latest commit: 997c658

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@mishushakov
Copy link
Member

  1. Does it still work with no env vars
  2. Does it still work when trying to override team id using --team?

@0div
Copy link
Contributor Author

0div commented Jul 7, 2025

  1. Does it still work with no env vars
  2. Does it still work when trying to override team id using --team?

yes, i updated the test description, do you mind testing on your machine for due diligence? thx

@mishushakov
Copy link
Member

how does it know what team to upload the template to if the team id is not provided?

@0div
Copy link
Contributor Author

0div commented Jul 8, 2025

how does it know what team to upload the template to if the team id is not provided?

it derives it from the access token

@mishushakov
Copy link
Member

But if it's a different one in the template.toml? Will it still be using my default team?

@0div
Copy link
Contributor Author

0div commented Jul 9, 2025

But if it's a different one in the template.toml? Will it still be using my default team?

Down the backend call stack of the handler for the request made here in the CLI client code, this is what determines the team ID, in other words it seems like no team ID is used.

/infra/packages/api/internal/handlers/auth.go

func (a *APIStore) GetUserAndTeams(c *gin.Context) (*uuid.UUID, []queries.GetTeamsWithUsersTeamsWithTierRow, error) {
	userID := a.GetUserID(c)
	ctx := c.Request.Context()

	teams, err := a.sqlcDB.GetTeamsWithUsersTeamsWithTier(ctx, userID)
	if err != nil {
		return nil, nil, fmt.Errorf("error when getting default team: %w", err)
	}

	return &userID, teams, err
}

@mishushakov
Copy link
Member

Yeah but the problem here it will always use the default team id or the one supplied as a parameter but will ignore e2b.toml?

@0div
Copy link
Contributor Author

0div commented Jul 10, 2025

Yeah but the problem here it will always use the default team id or the one supplied as a parameter but will ignore e2b.toml?

it also picks up the team id from e2b.toml

@jakubno
Copy link
Member

jakubno commented Jul 16, 2025

Down the backend call stack of the handler for the request made here in the CLI client code, this is what determines the team ID, in other words it seems like no team ID is used.

/infra/packages/api/internal/handlers/auth.go

The GetUserAndTeams returns a list of teams and based on provided team id, some team is selected

Copy link
Member

@jakubno jakubno left a comment

Choose a reason for hiding this comment

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

  1. This won't work if you have access to the template, but it isn't in your default team. It would require changes on backend (and it would probably make sense to check if ANY team you are part of has access to the template)

  2. If you don't use it, you don't need to save the team id

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