fix(streams): stop a bad byte from stalling transcript ingestion - #61
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
read_jsonl_line read each line with BufRead::read_line into a String, so any byte that was not valid UTF-8 returned an InvalidData io error. All eight agent readers wrapped that as StreamError::Transient, which the stream worker retried four times and then dropped. The condition is a property of the bytes at a fixed offset, not a temporary fault, so no retry could clear it. The watermark never advanced past that offset, and every later event in the session transcript was lost silently. Read the line as raw bytes with read_until(b'\n') and decode with String::from_utf8_lossy. A complete line that is not valid UTF-8 now decodes lossily and advances the offset; if the result is not valid JSON the reader skips it through the existing malformed-JSON path. A line without a trailing newline stays Partial, which also covers a half-written multi-byte character at the tail of a growing file. The signature is unchanged, so all eight readers keep working as before. Generated-By: PostHog Desktop Task-Id: e8a82875-b221-4b69-bc9d-0dcc050819ca
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.
Problem
read_jsonl_lineread each line withBufRead::read_lineinto aString, so any byte that is not valid UTF-8 came back as anInvalidDataio error. All eight agent readers undersrc/streams/agents/wrap that asStreamError::Transient, which the stream worker retries four times (5s, 30s, 5m, 30m) and then drops.Changes
read_until(b'\n')and decode withString::from_utf8_lossyinstead ofread_line.Partial, which keeps the concurrent-writer behavior and also covers a half-written multi-byte character at the tail of a growing file.Tests
Completewith the raw byte count and decodes to a replacement character; a bad line does not block the next line; a half-written multi-byte character with no newline staysPartial.Note
This sandbox has no Rust toolchain, so
task test,task lint, andtask fmtcould not run locally. CI exercises them on this PR.Agent context
&mut Stringsignature to stay minimal; the alternative (a&mut Vec<u8>buffer to reuse the allocation) would touch all eight callers for a negligible per-line cost next to JSON parsing.Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.