Skip to content

Add bk job environment - #1052

Merged
mcncl merged 7 commits into
mainfrom
feat/job_environment
Oct 23, 2026
Merged

mcncl merged 7 commits into
mainfrom
feat/job_environment

Conversation

@mcncl

@mcncl mcncl commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Description

Reading a job's environment currently requires constructing an API request. Add bk job environment <job-uuid> using the selected organization and existing authentication, without requiring pipeline or build identifiers.

Changes

  • Support the existing JSON, YAML, text, and output-format flags. Structured output preserves {"env":{"NAME":"value"}}; text prints sorted, escaped values.
  • Document the read_job_env token scope and warn that output may contain secrets.
  • Omit environment response bodies from debug logs, including redirected responses, and avoid echoing response data in API errors.
  • Cover values, empty results, authentication, format selection, errors, and redirect logging with synthetic CLI tests.
bk job environment <job-uuid> --json
bk job environment <job-uuid> --json | jq -r '.env.CI'

Testing

  • Tests have run locally (go test ./... -count=1, with the inherited API token unset)
  • Code is formatted (mise run format)

@mcncl
mcncl requested review from a team as code owners October 19, 2026 02:07

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No actionable defects found. The new unredacted job-environment output and its debug-log handling are L3 secrets handling, above the repository’s L2 approval ceiling, so this needs human approval.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

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

Install the reading-buildsworth-logs skill to run this.

About buildsworth

Model: gpt-6.1-sol with xhigh thinking.

How to request a review: Comment @buildsworth-bk review on the PR, or request buildsworth-bk as a reviewer.

Risk labels (how buildsworth classifies risk) — buildsworth classifies risk itself from the diff. Unless repository policy already allows L2 approval, grant it by mentioning @buildsworth-bk (see approval ceiling and L2 approval grant):

  • L1 — Low risk (dep bumps, docs/copy, lockfiles, small presentational fixes). buildsworth may approve by default.
  • L2 — Standard risk (new UI, additive API fields, refactors). Approved only when repository policy or a verified grant allows it; otherwise comment-only.
  • L3 — High risk (auth, migrations, payments, secrets, perf-critical pipeline paths). Human approval required unless repository policy explicitly allows L3 approval; per-PR grants cannot allow it.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No actionable defects found in the current revision. The unredacted job-environment output and sensitive-response debug logging are L3 secrets handling, above the repository’s L2 approval ceiling, so human approval is still needed.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

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

Install the reading-buildsworth-logs skill to run this.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No actionable defects found. The unredacted job-environment output and its debug-log protection are L3 secrets handling, so human approval is required.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

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

Install the reading-buildsworth-logs skill to run this.

Comment thread cmd/job/rest.go
if err != nil {
// SDK errors can contain raw response bodies or decoded values. Do not
// wrap them: environment data must only reach the requested output.
if resp != nil && resp.StatusCode >= 400 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we have special case for Rate Limiting/429s so it's more obvious rather than being bundled in with the other errors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, fair call;

if resp != nil && resp.StatusCode == http.StatusTooManyRequests {
	return buildkite.JobEnvs{}, fmt.Errorf("could not read job environment: rate limit exceeded (HTTP 429); try again later")
}

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No actionable defects found. The unredacted job-environment output and its debug-log protection are L3 secrets handling, so human approval is required.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

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

Install the reading-buildsworth-logs skill to run this.

Report HTTP 429 as a rate limit with retry-later advice instead of
suggesting changes to the job UUID, organization, or token scope.
Keep response data out of errors and preserve existing retry behavior.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No actionable defects found. The unredacted job-environment output and its debug-log protections are L3 secrets handling, so approval remains with a human reviewer.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

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

Install the reading-buildsworth-logs skill to run this.

@mcncl
mcncl merged commit 36d4290 into main Oct 23, 2026
2 checks passed
@mcncl
mcncl deleted the feat/job_environment branch October 23, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants