fix: correctly detect closing code fence in review comment extraction#213
Merged
fix: correctly detect closing code fence in review comment extraction#213
Conversation
The extract_review_comments parser was using a naive find("```") to
locate the closing fence of ```review-comments blocks. When the JSON
content contained embedded markdown code blocks (e.g. ```rust ...
```), the parser matched the first backtick-triple inside a JSON
string value, truncating the JSON and causing serde deserialization to
fail silently. This meant no review comments were ever extracted.
Replace the naive search with a find_closing_fence() helper that
requires the ``` to appear at column 0 (start of line) and be
followed only by EOF, a newline, or whitespace — distinguishing it
from opening fences with info-strings like ```rust and from
backticks embedded mid-line within JSON string values.
Add 15 unit tests covering find_closing_fence, extract_review_comments,
extract_note_content, and extract_note_title.
Replace the verbose match expression on remaining.find(fence) with the ? operator in find_closing_fence(). This resolves the clippy question_mark lint error that was causing CI to fail with -D warnings.
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.
Fix the
extract_review_commentsparser to correctly identify closing `````` fences forreview-commentscode blocks.Previously, the parser matched any occurrence of
as a closing fence, which caused false matches on embedded code fences likerust` within JSON string values. This broke review comment extraction when LLM responses contained nested code blocks.Changes:
find_closing_fence()helper that requires the `````` to appear at the start of a line and be followed only by whitespace/EOF (not an info-string likerustor `sql`)marker_endsubstring search with the new helper