Repository navigation
Register the stack's API token as a build token when the account has none (0.3.1) - #3
Merged
Merged
Conversation
…none
Without buildToken, a new configuration used the account's first build
token and failed when the account had none. The fix was one manual Git
connection in the dashboard. Now the provider reads the token id from
GET /user/tokens/verify and registers the stack's API token with
POST /accounts/{account_id}/builds/tokens as alchemy-<stack name>.
The order stays: buildToken, then the first existing build token, then
the registration. OAuth and global API key credentials keep the clear
WorkersBuildsError, because Workers Builds accepts only API tokens.
Destroy keeps the build token: it belongs to the account.
Unit tests use payloads from Cloudflare's API schema. They check the
order, the create body (the secret only by presence), and the OAuth
error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README now says when the provider registers the stack's API token as a build token, which permissions the deploy then needs (Workers Scripts: Edit, and R2, KV, D1 edit when the Wrangler file binds them), and that destroy keeps the build token. The limit that the package cannot make a build token is gone. No live run has registered one yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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
WorkersBuilds.Repositoryno longer needs a manual step in the Cloudflare dashboard on an account without a build token. Version0.3.1.buildToken, a new configuration used the account's first build token. With no build token on the account, the deploy failed and told you to connect a Worker to Git once in the dashboard, because the dashboard creates a build token.GET /user/tokens/verify(distilleduser.verifyToken), then callsPOST /accounts/{account_id}/builds/tokens(distilledworkersBuilds.createToken) withbuild_token_name: alchemy-<stack name>(Alchemy'sStackName),build_token_secret, andcloudflare_token_id.resolveBuildToken):buildToken, then the account's first build token, then the registration. An existing configuration keeps its token, as before.Credentials. Onlytype: "apiToken"can register. OAuth and global API key credentials keep the clearWorkersBuildsError, because Workers Builds accepts only API tokens. The create request is marked as holding the secret and is never logged.POST .../builds/tokensis in the same OpenAPI token group (Workers CI Write) as thePATCH .../builds/workerscall that already works withWorkers Builds Configuration: Edit, so registration needs no new permission. The README now says the token also needs the permissions of the deploy: Workers Scripts: Edit, and R2, KV, D1 edit when the Wrangler file binds them.What the unit tests prove
test/Repository.test.ts,resolveBuildToken, against a served HTTP client and payloads from Cloudflare's OpenAPI schema (user_tokens_verify.json,builds_tokens_create.json):buildTokenwins and makes no call.build_token_name: "alchemy-MyApp",cloudflare_token_idfrom the verify response, andbuild_token_secret, which the test checks only by presence, so a failure never prints it.WorkersBuildsError(operationregister build token), only the list call, no token in the message.build_token_uuidfails withWorkersBuildsError.pnpm run check: 79 passed, 3 skipped (the live tests, unchanged and pending).pnpm run buildpasses.Open points
GET /user/tokens/verifyis for user tokens. An account-owned token probably fails there (not tested): with HTTP 401 or 403 it becomesWorkersBuildsPermissionError, elseWorkersBuildsError. The README already says Workers Builds needs a user-scoped token.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.