You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(relay): end stream on bare [DONE] line in StreamScannerHandler - #7932
StreamScannerHandler accepts lines that start with either data: or [DONE], but then always ran data = data[5:]. When a line was a bare [DONE] with no data: prefix, that cut it down to "]". The "]" was then sent to the handler as a normal data frame, and scanning went on past the end of the stream.
The fix replaces the slice with strings.TrimPrefix(data, "data:"), so the prefix is removed only when it is present. A bare [DONE] now reaches the existing [DONE] branch: it sets the end reason to done, stops the scanner, and sends no frame. Handling of data: [DONE] and of normal data lines is unchanged.
Testing: I added TestStreamScannerHandler_BareDoneStopsScanner. It feeds in data: {"id":1}\n[DONE]\ndata: {"id":2}\n and checks that only {"id":1} is forwarded and that the end reason is done. The test fails on main, where the end reason comes back as eof, and passes with this change. go test ./relay/helper/, go vet and gofmt all pass.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: faa9e68e-3c6f-4b94-ada1-dedecfcc20e8
📥 Commits
Reviewing files that changed from the base of the PR and between 206e0fa and cfe4dba.
📒 Files selected for processing: 2
relay/helper/stream_scanner.go
relay/helper/stream_scanner_test.go
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Walkthrough
The stream scanner now removes the data: prefix only when present. A bare [DONE] marker is preserved and ends scanning. A test checks that later data is not processed and that the end reason is recorded as StreamEndReasonDone.
Changes
Stream termination
Layer / File(s)
Summary
Preserve and verify bare [DONE] markers relay/helper/stream_scanner.go, relay/helper/stream_scanner_test.go
The scanner conditionally removes the data: prefix. The new test verifies that a bare [DONE] stops scanning, later data is ignored, and StreamEndReasonDone is recorded.
The PR addresses bare [DONE] stream termination without identified merge-blocking risk.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: ending StreamScannerHandler processing on a bare [DONE] line.
Linked Issues check
Issue [#7929] requires bare [DONE] to terminate StreamScannerHandler, forward only preceding data, and avoid the erroneous "]" frame. The change replaces the unconditional five-character slice w…
Out of Scope Changes check
The pull request changes only the shared stream scanner logic and adds a focused regression test for issue [#7929]. Both changes directly support bare [DONE] handling. No unrelated production behavi…
Full details: Linked Issues check
Explanation
Issue [#7929] requires bare [DONE] to terminate StreamScannerHandler, forward only preceding data, and avoid the erroneous "]" frame. The change replaces the unconditional five-character slice with strings.TrimPrefix(data, "data:"), so the existing [DONE] branch receives the bare marker. TestStreamScannerHandler_BareDoneStopsScanner verifies that only {"id":1} is forwarded and that StreamEndReasonDone is recorded. The diff also preserves handling for prefixed data and data: [DONE].
Full details: Out of Scope Changes check
Explanation
The pull request changes only the shared stream scanner logic and adds a focused regression test for issue [#7929]. Both changes directly support bare [DONE] handling. No unrelated production behavior or unrelated test coverage appears in the reviewed diff.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit watched the data stream, Then saw [DONE] end the stream. No later frame hopped into view, The end reason was recorded too. The rabbit twitched its nose: all through!
Comment @coderabbitai help to get the list of available commands.
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
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.
StreamScannerHandler accepts lines that start with either
data:or[DONE], but then always randata = data[5:]. When a line was a bare[DONE]with nodata:prefix, that cut it down to"]". The"]"was then sent to the handler as a normal data frame, and scanning went on past the end of the stream.The fix replaces the slice with
strings.TrimPrefix(data, "data:"), so the prefix is removed only when it is present. A bare[DONE]now reaches the existing[DONE]branch: it sets the end reason todone, stops the scanner, and sends no frame. Handling ofdata: [DONE]and of normal data lines is unchanged.Testing: I added
TestStreamScannerHandler_BareDoneStopsScanner. It feeds indata: {"id":1}\n[DONE]\ndata: {"id":2}\nand checks that only{"id":1}is forwarded and that the end reason isdone. The test fails on main, where the end reason comes back aseof, and passes with this change.go test ./relay/helper/,go vetandgofmtall pass.🤖 Generated with Claude Code
Fixes #7929
This change was prepared with an AI coding agent (Claude) and reviewed by me before submitting. I'm happy to make any changes you'd like.
Summary by CodeRabbit
[DONE]signals.