fix(helpers): clearer error when project ID is missing#511
Draft
jacobwgillespie wants to merge 1 commit into
Draft
fix(helpers): clearer error when project ID is missing#511jacobwgillespie wants to merge 1 commit into
jacobwgillespie wants to merge 1 commit into
Conversation
When a depot build is started without a project ID (no --project flag, DEPOT_PROJECT_ID env var, or depot.json), BeginBuild used to call the NewBuild API with an empty project_id. That returned CodeNotFound, which triggered the OnboardProject -> RetrieveProjects path. In CI (e.g. depot/build-push-action with an OIDC token that has no list-projects scope) RetrieveProjects fails with 'permission_denied: Not authorized', which is misleading: the real problem is the missing project ID, not authentication. Detect the empty project ID up front in BeginBuild and return a clear, actionable error pointing at all the supported ways to configure a project ID (CLI flag, env var, depot.json). Fixes DEP-4447. Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
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
When
depot build(or any caller ofhelpers.BeginBuild) is run without a project ID β no--projectflag, noDEPOT_PROJECT_ID, and nodepot.jsonβResolveProjectIDreturns an empty string. We then sent an emptyproject_idto theNewBuildAPI, which responds withCodeNotFound. That triggered the interactive onboarding path (OnboardProjectβInitializeProjectβRetrieveProjects). In CI (notablydepot/build-push-actionwith an OIDC token that has no list-projects scope),RetrieveProjectsfails with:That message is misleading β it points users at authentication when the real fix is providing a project ID.
Change
In
pkg/helpers/build.go, detect an emptyreq.ProjectIdup front inBeginBuild(when we're not resuming viaDEPOT_BUILD_ID) and return a clear, actionable error that lists all supported ways to configure a project:This is exposed as
ErrMissingProjectIDso callers canerrors.Isit if needed. AllBeginBuildcallers (build,bake,buildctl dial-stdio,exec) benefit automatically, including viadepot/build-push-actionwhich shells out to the CLI.Test
Added
pkg/helpers/build_test.gocovering both thenilProjectIdpointer and an empty-stringProjectId, and asserting the message stays actionable.Notes
The issue references
depot/build-push-action@v1, but the error message itself originates indepot/cli(pkg/helpers/project.go:RetrieveProjects), and the issue is labeleddepot/cli. Fixing it here means every caller of the CLI (including the GitHub Action, which shells out todepot build) gets the better message without an Action release.Linear Issue: DEP-4447