-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Found during deep code review of #28 and #8
1. `find_balanced_bracket_span` doesn't track string literals (llm_response.rs:314-330)
Unlike `find_balanced_json` (which tracks `in_string`), the bracket span fallback counts brackets naively. A JSON value containing `]` or `}` terminates the span early:
```json
[{"issue": "check array[0]"}]
```
The `]` inside the value closes the bracket at the wrong position.
2. `generate_code_suggestion` ships placeholder text (suggestions.rs:11-16)
When a suggestion text exists but no structured code suggestion, it creates:
```rust
original_code: "// Original code would be extracted from context"
```
This placeholder can appear in real GitHub suggestion blocks, proposing to replace a nonexistent comment line with the suggestion text.
3. Triple backticks in `suggested_code` break suggestion blocks (api.rs:3157)
```rust
format!("\n```suggestion\n{}\n```", cs.suggested_code)
```
If `suggested_code` contains `````, the markdown is malformed. GitHub renders the first ```` as closing the block; the rest appears as raw text.
4. Multi-line suggestion `start_line` is wrong (api.rs:3180)
`start_line` is set to `c.line_number` (where the issue was reported), not the first line of the original code being replaced. If the issue is on line 50 but the code spans lines 48-52, the suggestion targets lines 50-54 instead.
5. No GitHub API body size limit check
GitHub limits review comment bodies to 65536 characters. Large code suggestions can exceed this; the API call fails with no truncation logic.
6. `parse_primary` skips all lines starting with `#` or `<` (line 115-116)
This drops valid output like `#1: Line 5 has a bug` and any XML-structured response.
Acceptance
- `find_balanced_bracket_span` tracks string contexts
- Remove or replace placeholder `original_code` string
- Escape or reject backticks in `suggested_code`
- Fix `start_line` to use original code position, not comment line
- Add body size check with truncation
- Refine `#`/`<` line skip logic
🤖 Generated with Claude Code