-
Notifications
You must be signed in to change notification settings - Fork 137
fixing cloud agents log streaming early exit based on actual logs being received #834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughRemoved a runtime check that scanned log lines for an "ERROR:" prefix; log lines are now written to the provided writer unconditionally. A new test suite for Client.StreamLogs was added covering writer errors, context cancellation, non-OK responses, and server disconnects. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)pkg/cloudagents/logs_test.go (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (3)
✏️ Tip: You can disable this entire section by setting Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@pkg/cloudagents/logs_test.go`:
- Around line 188-190: The test currently checks error text with
strings.Contains(err.Error(), "scanner error") and "unexpected EOF" but only
calls t.Logf when neither matches, so unexpected errors don't fail the test;
update the assertion: replace the t.Logf call with t.Errorf (or t.Fatalf) to
fail the test and include the actual err and expected substrings in the message,
e.g. reference the existing err variable and strings.Contains checks so the test
fails on unexpected error text; alternatively, if any error is acceptable,
remove the strings.Contains conditional entirely and assert that err != nil (or
adjust the test to explicitly document acceptance).
🧹 Nitpick comments (1)
pkg/cloudagents/logs_test.go (1)
19-54: Potential test flakiness: discarded pipe reader may cause writes to block.The test creates an
io.Pipe()but discards the reader (pr). Writes to aPipeWriterwithout an active reader will block until the pipe is closed. This means the test relies on timing behavior wherepw.Close()unblocks the write after 100ms.If the intent is to test writer closure, consider using
io.Pipe()with a goroutine that reads and discards data, or use a custom writer that closes after a threshold (similar tofailingWriter). This would make the test more deterministic.♻️ Suggested improvement
func TestStreamLogs_WriterClosesEarly(t *testing.T) { - _, pw := io.Pipe() + pr, pw := io.Pipe() + + // Drain the pipe to prevent blocking writes + go func() { + io.Copy(io.Discard, pr) + }() server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pkg/cloudagents/logs.gopkg/cloudagents/logs_test.go
💤 Files with no reviewable changes (1)
- pkg/cloudagents/logs.go
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/cloudagents/logs_test.go (2)
pkg/cloudagents/client.go (1)
Client(34-44)pkg/cloudagents/logs.go (1)
APIError(27-30)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (3)
pkg/cloudagents/logs_test.go (3)
56-89: LGTM!The test correctly validates context cancellation behavior using
errors.Is()for proper error unwrapping.
91-130: LGTM!The
failingWriterprovides a clean, deterministic way to test write failure scenarios. The test correctly validates error handling when the writer fails.
132-157: LGTM!The test properly validates error handling for non-OK HTTP responses with the
APIErrorpayload structure.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
yoonsio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice find!
|
Caution Docstrings generation - FAILED No docstrings were generated. |
Any log line received from the upstream sdk or user code prefixed with
ERROR:would stop the log streaming and not show the full output of the message. ThisERROR:check had previously been used to close the writer once the upstream sent the message; this has been solved on the server side by correctly closing the writer when an error is found.also adds some tests to simulate various failure and writer close modes.
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.