Migrate bk job retry from GraphQL to REST#853
Open
jeremybumsted wants to merge 2 commits into
Open
Conversation
Contributor
If it uses the |
lox
requested changes
Jun 5, 2026
| type RetryCmd struct { | ||
| JobID string `arg:"" help:"Job UUID to retry"` | ||
| JobID string `arg:"" help:"Job UUID to retry"` | ||
| Pipeline string `help:"The pipeline to use. This can be a {pipeline slug} or in the format {org slug}/{pipeline slug}" short:"p"` |
Contributor
There was a problem hiding this comment.
Isn't this a breaking change that requires Pipeline and Build number for this command? We added new APIs recently that we used for #833 can we lean on them?
Author
Author
There was a problem hiding this comment.
@catkins I think ☝️ addresses your comment, shouldn't need org/<slug>/jobs/<uuid> and I've since updated to remove that note
Retries now go through the REST API using the same pipeline/build resolution as `bk job log` and `bk job reprioritize`: pipeline comes from the `-p` flag, configured pipeline, or the current git repository; build comes from the `-b` flag or the most recent build on the current branch. Why: the GraphQL path required a GraphQL-enabled token and was the odd one out among job commands — it predates the resolver pattern (it was copied from `job unblock` in #387). REST works with standard token scopes and keeps one consistent code path. Behavior change: `bk job retry <uuid>` no longer works with zero context from outside a configured repository — pass `-p` and `-b` explicitly, like other job commands. Without `-b`, the job is assumed to be in the latest build on the current branch. Also removes the retry GraphQL operation and its generated code; this incidentally fixes the nil-payload crash path previously guarded in retry.go (REST errors now surface cleanly).
Use PUT /v2/organizations/:org/jobs/:job_id/retry (added in buildkite/buildkite#29824, adopted for other job commands in #833) instead of the build-scoped retry endpoint. This keeps `bk job retry <uuid>` working with only a job UUID and a selected organization — no pipeline or build context, no -p/-b flags, and no behavior change from the GraphQL version it replaces.
8997fa0 to
e6ba94c
Compare
catkins
approved these changes
Jun 6, 2026
Contributor
catkins
left a comment
There was a problem hiding this comment.
👌 excellent, thanks @jeremybumsted 🚀
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.
Description
bk job retrywas one of the last job commands using the GraphQL API — itpredates the pipeline/build resolver pattern and was copied from
job unblockin #387.This migrates it to the REST API using the organization-level job route added
in buildkite/buildkite#29824 (
PUT /v2/organizations/:org/jobs/:job_id/retry) — the same API surface #833adopted for
bk job log,bk job reprioritize, andbk job unblock. JobUUIDs are globally unique, so the selected organization plus the UUID is all
the context needed.
Why REST: works with standard token scopes (no GraphQL-enabled token
required), and keeps job commands on one consistent pattern.
An earlier revision of this PR used the build-scoped retry endpoint, which
required resolving a pipeline and build (
-p/-bflags) and would havebroken
bk job retry <uuid>outside a configured repository. Review caughtthis — the org-level route avoids it entirely.
No behavior change:
bk job retry <uuid>works with just a job UUID anda selected organization, from anywhere — same as the GraphQL version it
replaces, and same as the other job commands after #833.
Changes
cmd/job/retry.go: rewritten to mirrorreprioritize.go— requires aselected organization, calls the org-level retry route by job UUID
cmd/job/rest.go: adds aretryJobhelper alongside the existinggetJobLog/reprioritizeJob/unblockJoborg-route helpers from fix: Use organization job routes #833cmd/job/retry_test.go: asserts method, org-level path, and emptyrequest body, matching the fix: Use organization job routes #833 test style
cmd/job/graphql/retry.graphqland its generated code(
internal/graphql/generated.go, −97 lines)retrying a job from a canceled build) now surface cleanly via the API error
New help output:
Testing
go test ./...)go fmt ./...)Additional checks run:
golangci-lint run— 0 issuesmise run vulncheck— cleanmise run generate— no drift;generated.gomatches codegen exactlyNotes
mainto pick up the fix: Use organization job routes #833 helpers, so this branch wasforce-pushed.
Disclosures / Credits
Claude Code (Opus 4.8) wrote this change end-to-end — exploration, planning,
implementation, and this PR description — with me reviewing and directing.