Skip to content

Surface secret fetch retry warnings in job output#3714

Open
blaknite wants to merge 1 commit intomainfrom
gc/a-959-secret-retry-warnings
Open

Surface secret fetch retry warnings in job output#3714
blaknite wants to merge 1 commit intomainfrom
gc/a-959-secret-retry-warnings

Conversation

@blaknite
Copy link
Copy Markdown
Member

Description

The buffer logger (logger.NewBuffer()) passed to secrets.FetchSecrets was never flushed, so when secret fetching hit retryable errors (HTTP 502, 429, TLS timeouts), the l.Warn() calls about retries went into the buffer and vanished. Users would see their step appear to hang with no explanation of what was happening.

The buffer logger was originally introduced in #3453 to satisfy api.NewClient's logger requirement and suppress debug HTTP header noise. When retry logic was added in #3706, FetchSecrets reused the same buffer logger without accounting for the fact that it now produces meaningful warnings.

After FetchSecrets returns, we now iterate the buffer's messages and forward any warnings to the shell logger so they appear in the job output.

Context

A-959

Changes

After FetchSecrets completes, warning messages from the buffer logger are forwarded to the shell logger. The API client keeps its buffer logger to suppress debug noise.

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go tool gofumpt -extra -w .)

Disclosures / Credits

Amp wrote the implementation.

The buffer logger passed to secrets.FetchSecrets was never flushed,
so retry warnings (HTTP 502, 429, TLS timeouts) were silently
swallowed. Steps would appear to hang with no explanation.

After FetchSecrets returns, we now iterate the buffer's messages and
forward any warnings to the shell logger so they appear in the job
log.

Fixes A-959

Amp-Thread-ID: https://ampcode.com/threads/T-019c78c7-5821-71f5-a011-2fe9f58b9cb4
Co-authored-by: Amp <amp@ampcode.com>
@blaknite blaknite requested a review from a team February 20, 2026 02:16
Copy link
Copy Markdown
Contributor

@zhming0 zhming0 left a comment

Choose a reason for hiding this comment

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

I can see the rationale 👍🏿 , but I think it might be worth to re-look this implementation in security perspective.

Comment thread internal/job/executor.go
Comment on lines +918 to +920
// Fetch all secrets. We pass secretLogger (a buffer) here because
// FetchSecrets takes a logger.Logger, but retry warnings within it need
// to reach the user. We flush those from the buffer afterwards.
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.

This entire comment read a bit logically odd and misplaced 😅

We pass secretLogger (a buffer) here because FetchSecrets takes a logger.Logger, but retry warnings...

And i think this comment should just be added around the flushing code rather than here.

Comment thread internal/job/executor.go
if after, ok := strings.CutPrefix(msg, "[warn] "); ok {
e.shell.Warningf("%s", after)
}
}
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.

Is this partially defeating the purpose of using Buffer logger? We haven't mutate redactor at this point, so we are running the risk of exposing secrets to log here.

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