Skip to content

fix: stream CircleCI action output#4949

Open
Big-Comfy wants to merge 1 commit into
trufflesecurity:mainfrom
Big-Comfy:circleci-stream-output
Open

fix: stream CircleCI action output#4949
Big-Comfy wants to merge 1 commit into
trufflesecurity:mainfrom
Big-Comfy:circleci-stream-output

Conversation

@Big-Comfy
Copy link
Copy Markdown

@Big-Comfy Big-Comfy commented May 4, 2026

Description:

CircleCI action output is build-log data, but this path was reading the whole response body before passing it to the chunker. Large step output can make the source hold much more data in memory than it needs to.

This keeps the response body as a stream and passes it straight into the existing chunk reader. The CircleCI config string still goes through the same chunk path with a strings.Reader.

The output fetch now also returns an error for 4xx/5xx responses, draining and closing the response body before returning.

This follows the same idea as the Jenkins build-log streaming fix in #4225, but keeps the change scoped to the CircleCI source.

Tests:

  • GOCACHE=/Users/nsatyakrishna/Sandbox/.cache/go-build GOMODCACHE=/Users/nsatyakrishna/Sandbox/.cache/go-mod go test ./pkg/sources/circleci -run 'Test(GetOutputUrlResponseStreamsBody|ChunkReadsFromReader)'
  • make lint

I ran the source-specific tests here because make test-community skips pkg/sources, so it does not cover this change.

Checklist:

  • Targeted tests passing
  • Lint passing

@Big-Comfy Big-Comfy requested a review from a team May 4, 2026 19:16
@Big-Comfy Big-Comfy requested a review from a team as a code owner May 4, 2026 19:16
Comment on lines +345 to +348
if resp.StatusCode >= http.StatusBadRequest {
_, _ = io.Copy(io.Discard, resp.Body)
_ = resp.Body.Close()
}()

bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("failed to read response body: %w", err)
return nil, fmt.Errorf("unexpected status code: %d while fetching action output", resp.StatusCode)
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.

Maybe we should add this new behavior in the PR description.

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