Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
// The function uses a ring buffer to efficiently store only the last maxJobLogLines lines.
// If the response contains more lines than maxJobLogLines, only the most recent lines are kept.
func ProcessResponseAsRingBufferToEnd(httpResp *http.Response, maxJobLogLines int) (string, int, *http.Response, error) {
if maxJobLogLines > 100000 {
maxJobLogLines = 100000
}
Comment on lines +29 to +31
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The new capping behavior lacks test coverage. Consider adding a test case in a new pkg/buffer/buffer_test.go file to verify that:

  1. Values at or below 100,000 are not modified
  2. Values above 100,000 are capped to 100,000
  3. The function still works correctly when the cap is applied

This is particularly important since this safeguard was added to prevent a panic, and we should have tests to ensure it works as expected.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +31
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The function documentation should be updated to reflect the new behavior where maxJobLogLines is capped at a maximum value. The documentation currently states that the function will retain "the last maxJobLogLines lines" but doesn't mention that values exceeding 100,000 will be silently reduced.

Consider updating the documentation to include:

// Parameters:
//
//	httpResp:        The HTTP response whose body will be read.
//	maxJobLogLines:  The maximum number of log lines to retain (capped at 100,000).

And add a note in the function description explaining this safeguard.

Copilot uses AI. Check for mistakes.

lines := make([]string, maxJobLogLines)
validLines := make([]bool, maxJobLogLines)
totalLines := 0
Expand Down