Skip to content

fix: Use organization job routes#833

Merged
lox merged 2 commits into
mainfrom
lox/job-unblock-rest
May 26, 2026
Merged

fix: Use organization job routes#833
lox merged 2 commits into
mainfrom
lox/job-unblock-rest

Conversation

@lox
Copy link
Copy Markdown
Contributor

@lox lox commented May 20, 2026

Description

bk job log, bk job reprioritize, and bk job unblock all take a job UUID, but the REST-backed command paths still required pipeline or build context. That made bk job log <job-uuid> fail with failed to resolve a pipeline outside a pipeline checkout, and forcing callers to pass pipeline/build identifiers would change the existing UUID-only command shape.

The CLI now calls the new organization-level job REST routes directly under the selected organization. This keeps UUID-only job commands working, avoids scanning builds, and uses the same API surface we added in buildkite/buildkite#29824. The existing --pipeline and --build flags on job log and job reprioritize remain accepted for compatibility, but now emit a stderr warning when supplied because they are ignored.

Changes

  • Add shared REST helpers for /v2/organizations/:org/jobs/:job_id/{log,reprioritize,unblock}.
  • Update bk job log to fetch logs directly by job UUID.
  • Update bk job reprioritize to reprioritize directly by job UUID.
  • Update bk job unblock to unblock directly by job UUID while preserving --data and stdin fields.
  • Require a selected organization before constructing organization-scoped job route requests.
  • Warn when deprecated --pipeline or --build context flags are supplied to UUID-only job commands.
  • Update command tests to assert the organization-level paths, methods, headers, request bodies, missing-organization guard, deprecated flag warning, and already-unblocked REST error handling.

Relevant examples now work without pipeline or build context:

bk job log 019e6209-ac2a-4d32-84c7-2abcee10099c
bk job reprioritize 019e6209-ac2a-4d32-84c7-2abcee10099c 10
bk job unblock 019e6209-ac2a-4d32-84c7-2abcee10099c --data '{"name":"value"}'

Testing

  • Tests have run locally (with go test ./...)
  • Code is formatted (with go fmt ./...)

Additional checks run:

  • mise exec -- go test ./cmd/job
  • mise exec -- go test ./cmd/job ./internal/pipeline/resolver ./internal/build/resolver
  • mise run build
  • mise run test
  • mise run lint
  • live ./dist/bk job log 019e6209-ac2a-4d32-84c7-2abcee10099c --no-pager
  • live safe ./dist/bk job unblock 019e6209-ac2a-4d32-84c7-2abcee10099c --no-pager returned 400 This job type cannot be unblocked
  • live safe ./dist/bk job reprioritize 019e6209-ac2a-4d32-84c7-000000000000 10 --no-pager returned 404 No job found

Disclosures / Credits

Codex implemented and validated this update with human direction. The organization-level REST API routes were added separately in buildkite/buildkite#29824.

@lox lox marked this pull request as ready for review May 20, 2026 21:54
@lox lox requested review from a team as code owners May 20, 2026 21:54
Copy link
Copy Markdown

@Megh03 Megh03 left a comment

Choose a reason for hiding this comment

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

LGTM @lox ! Was just a little curious on the pagination side, like for large orgs with many builds, with the current code . the job lookup could paginate through a lot of pages before finding the job . But I think it's a fair tradeoff to make 🤔

@lox
Copy link
Copy Markdown
Contributor Author

lox commented May 20, 2026

Yeah, I don't love the pagination approach, I don't think it will be viable.

The challenge is that currently this command doesn't need a pipeline identifier, as the GraphQL endpoint is job UUID only, where as the REST API needs /v2/organizations/:org/pipelines/:pipeline/builds/:build/jobs/:job_id/unblock.

I think realistically we either need to require an optional --pipeline and switch between GraphQL and REST (which would be gross), or add a new REST endpoint for this.

@lox lox marked this pull request as draft May 20, 2026 23:00
@lox
Copy link
Copy Markdown
Contributor Author

lox commented May 20, 2026

Converting back to draft whilst we figure it out.

@lox lox force-pushed the lox/job-unblock-rest branch from 348e280 to 79c57bc Compare May 26, 2026 02:49
@lox lox changed the title fix: Unblock jobs over REST fix: Use organization job routes May 26, 2026
@lox lox added the risk:l1 label May 26, 2026
@lox
Copy link
Copy Markdown
Contributor Author

lox commented May 26, 2026

@buildsworth-bk review please

Copy link
Copy Markdown

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Choose a reason for hiding this comment

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

Overall this looks clean and focused — UUID-only commands now work without pipeline context, the helpers in rest.go are small and uniform, and the test coverage exercises path/method/body for each new endpoint. The GraphQL → REST swap for unblock is the most behaviorally significant piece; the isAlreadyUnblocked string match mirrors the existing pattern in cmd/preflight/preflight.go, so it's consistent.

One note on the risk:l1 label: I'd read this closer to L2 than L1. It's not a typo/dep-bump/lockfile change — it switches the verb (GraphQL → REST) for bk job unblock, changes how --data is parsed (must now be a JSON object, previously the raw string was forwarded), and silently drops two previously-functional flags on log and reprioritize. The behavior changes are intentional and tested, but they're the kind of "non-trivial logic" L2 calls for a human sanity-check on rather than AI-only review. Just one Tier-2 question inline.

Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:

Download the buildsworth logs from build 241, then answer my questions about the findings.

Comment thread cmd/job/log.go Outdated
@lox lox marked this pull request as ready for review May 26, 2026 05:41
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: 79c57bc938

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/job/log.go Outdated
Comment thread cmd/job/reprioritize.go Outdated
Comment thread cmd/job/rest.go
Comment thread cmd/job/unblock.go Outdated
@lox
Copy link
Copy Markdown
Contributor Author

lox commented May 26, 2026

@codex review

@lox
Copy link
Copy Markdown
Contributor Author

lox commented May 26, 2026

Review follow-up: I checked the risk labels and this repo currently only has risk:l1, so I left the label unchanged. The inline feedback is addressed in 97a9925.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lox lox merged commit 21b2811 into main May 26, 2026
3 checks passed
@lox lox deleted the lox/job-unblock-rest branch May 26, 2026 17:11
jeremybumsted added a commit that referenced this pull request Jun 5, 2026
   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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants