fix: Unblock jobs over REST#833
Conversation
Megh03
left a comment
There was a problem hiding this comment.
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 🤔
|
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 I think realistically we either need to require an optional |
|
Converting back to draft whilst we figure it out. |
Description
bk job unblockcurrently uses the GraphQLjobTypeBlockUnblockmutation. Tokens created throughbk auth logindo not request the unscoped GraphQL access level, so the command can fail even though the REST API already supports unblocking jobs with normal build API scopes.The existing REST unblock endpoint is nested under organization, pipeline, and build. Requiring users to pass
--pipelineor--buildwould break the currentbk job unblock <job-uuid>contract, so this keeps that command shape: the CLI first looks up the job UUID in the organization builds REST index, then calls the existing nested REST unblock endpoint once it has the pipeline slug and build number.This uses the default
bk auth loginREST scopes (read_buildsfor lookup andwrite_buildsfor unblock) and avoids requiring GraphQL access. The tradeoff is that old jobs may require deeper build pagination until we add a direct job lookup/unblock endpoint and simplify this path.Changes
GET /v2/organizations/:org/buildsover REST, including retried jobs and following pagination.PUT /v2/organizations/:org/pipelines/:pipeline/builds/:build/jobs/:job_id/unblockwith the existing JSONfieldspayload.bk job unblock <job-id>plus optional--dataor stdin fields.Relevant help remains:
Testing
go test ./...)go fmt ./...)Additional checks run:
mise exec -- go test ./cmd/jobenv -u PAGER mise exec -- go test ./...mise run lintmise run formatmise run vulncheckmise exec -- go run main.go job unblock --helpgit diff --checkDisclosures / Credits
Codex drafted and validated this change based on the Slack thread diagnosis and review feedback.