Problem
When the AI returns feedback points, the file_name and line_numbers values aren't validated against the actual PR diff before being sent to the GitHub API. This causes silent failures:
- If the AI references a file not in the PR, GitHub rejects the review
- If the AI returns a line number outside the valid range, GitHub rejects the review
- When this happens, the
POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews call returns 422 and no comments get posted at all -even valid ones are lost
Steps to reproduce
- Trigger a review on a PR where the AI returns a feedback point referencing a file not in the diff, or a line number beyond the file length
- The review request to GitHub fails with 422
- No review comments appear on the PR
Suggested fix
In handleLabeled.ts, after getting the AI feedback and before calling postInlineComments, filter each feedback point:
- Verify
point.file_name matches a file returned by getPRFiles
- Verify each line number in
point.line_numbers is within the range of lines in that file's patch
This could be a utility function like validateFeedbackPoints(points: FeedbackPoint[], files: PRFile[]) that returns only the valid points. Invalid points could be logged to console for debugging.
Problem
When the AI returns feedback points, the
file_nameandline_numbersvalues aren't validated against the actual PR diff before being sent to the GitHub API. This causes silent failures:POST /repos/{owner}/{repo}/pulls/{pull_number}/reviewscall returns 422 and no comments get posted at all -even valid ones are lostSteps to reproduce
Suggested fix
In
handleLabeled.ts, after getting the AI feedback and before callingpostInlineComments, filter each feedback point:point.file_namematches a file returned bygetPRFilespoint.line_numbersis within the range of lines in that file's patchThis could be a utility function like
validateFeedbackPoints(points: FeedbackPoint[], files: PRFile[])that returns only the valid points. Invalid points could be logged to console for debugging.