Skip to content

fix(ai-review): don't fail the whole review when inline lines can't anchor#99

Merged
vineethkrishnan merged 1 commit into
mainfrom
fix/review-unresolvable-lines
Jun 14, 2026
Merged

fix(ai-review): don't fail the whole review when inline lines can't anchor#99
vineethkrishnan merged 1 commit into
mainfrom
fix/review-unresolvable-lines

Conversation

@vineethkrishnan

Copy link
Copy Markdown
Owner

Problem (found by dogfooding)

ClearPR reviewed its own docs PR (#98, markdown) and posted "Review failed: Unprocessable Entity: 'Line could not be resolved'" three times instead of a review.

pulls.createReview posts all inline comments in one call; if any comment's line isn't part of the PR diff, GitHub 422s the entire review. For unsupported languages (markdown here) the semantic diff falls back to whitespace filtering, so the LLM's line numbers don't map to diff positions. ClearPR let the 422 propagate, which posted a failure comment and dropped every finding (the summary only shows counts, not bodies).

Fix

  • ReviewPosterPort.postInlineComments now returns boolean, true if anchored, false if GitHub couldn't resolve the lines. Other errors still throw.
  • The adapter catches the 422 (GitHubApiError.statusCode, newly exposed) and degrades with a warning instead of failing.
  • When not anchored, BuildReviewSummaryUseCase lists each finding as text ([severity] path:line body) so findings are preserved. Refactored into a helper to stay under the complexity gate.

Result

Markdown / unsupported-language PRs get a real review summary with findings instead of a "Review failed" comment. Inline anchoring still works for supported languages.

Tests

New summary-builder test for the unanchored path; updated the e2e fake poster. Full suite 175/175, tsc/eslint/complexity/build clean.

Note

Future improvement (not here): post per-comment so resolvable lines still anchor even when some don't.

…nchor

GitHub rejects an entire pulls.createReview call with 422 "Line could not be resolved" when any comment targets a line outside the PR diff, common for unsupported languages where the semantic diff falls back to whitespace filtering and line numbers no longer map to diff positions. ClearPR let that 422 fail the review and post a "Review failed" comment, losing all findings (surfaced by ClearPR reviewing its own markdown docs PR).

Now postInlineComments returns whether the comments anchored. On a 422 it degrades instead of throwing, and the summary lists the findings as text (severity, path:line, body) so nothing is lost. Other errors still propagate. Adds statusCode to GitHubApiError for precise detection and a summary-builder test for the fallback path.
@vineethkrishnan vineethkrishnan merged commit b67aed2 into main Jun 14, 2026
13 checks passed
@vineethkrishnan vineethkrishnan deleted the fix/review-unresolvable-lines branch June 14, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant