fix: stream CircleCI action output#4949
Open
Big-Comfy wants to merge 1 commit into
Open
Conversation
shahzadhaider1
approved these changes
May 5, 2026
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) |
Contributor
There was a problem hiding this comment.
Maybe we should add this new behavior in the PR description.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 lintI ran the source-specific tests here because
make test-communityskipspkg/sources, so it does not cover this change.Checklist: