Repository navigation
Logs → fix messages containing new lines corrupting format - #121
Merged
Merged
Conversation
revett
approved these changes
Jul 23, 2026
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.
resolves #97
Problem
Persisted log lines are newline delimited and messages are written verbatim. An error message containing a newline (common in thrown I/O and provider errors) splits into one valid line plus malformed continuation lines that the parser silently drops, so the most interesting half of an error never appears in the log view.
formatLogLinewrote messages verbatim; any \n in the message broke the line delimiter and parseLogLine silently dropped the continuation lines.Changes
Added
escapeMessage/unescapeMessageat the serialization boundary. formatLogLine escapes , \n, \r before writing; parseLogLine unescapes them after reading. Unescape uses character-by-character scanning to avoid matching \n inside the stored \ sequence.Tests
Eight new cases, round-trips for embedded newline, CR, literal backslash-n, both together, multiple newlines, CRLF; a single-line guarantee check; and an adapter split-and-parse simulation.
Greptile Summary
This PR fixes log corruption caused by error messages containing newlines being written verbatim into a newline-delimited log file, causing the parser to silently drop the continuation lines. It also upgrades the 404 check in
readRemoteManifestfrom message-text sniffing to the properstatusfield.escapeMessage(escape\→\\,\n→\n,\r→\r) andunescapeMessage(character-by-character scanner) at theformatLogLine/parseLogLineboundary inlog.ts. The escape ordering (backslash first) correctly prevents literal\nsequences from being misread, and the scanner correctly handles\\nwithout consuming thenas an escape target.fetched.message.includes("(404)")sniff insync.tswithfetched.status === "not_found", closing the TODO added in Results conflate 404 with other errors #41 now thatResultStatuscarries a proper discriminant.Confidence Score: 5/5
Safe to merge — the escape/unescape logic is correct in all tested and edge cases, and the sync status check is a straightforward improvement.
The escape ordering (backslash before newline) and the character-by-character unescape scanner are both implemented correctly and verified across eight round-trip cases including the tricky
ambiguity. The sync.ts change removes a fragile string-sniff in favour of the typed status discriminant that already existed on GetResult.
No files require special attention.
Important Files Changed
Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/log-format" | Re-trigger Greptile