Skip to content

fix(tool): swap inverted file_read line range instead of erroring - #1222

Open
seamnniel wants to merge 1 commit into
alibaba:mainfrom
seamnniel:fix/file-read-inverted-range
Open

fix(tool): swap inverted file_read line range instead of erroring#1222
seamnniel wants to merge 1 commit into
alibaba:mainfrom
seamnniel:fix/file-read-inverted-range

Conversation

@seamnniel

Copy link
Copy Markdown

Summary

file_read hard-errors when the model passes end_line < start_line:

file_read failed: invalid line range: start_line 430 is greater than end_line 120

This is a common model slip — the model derives start_line from the old side of a diff hunk while end_line comes from the new file's length. One bad call fails the whole file's review item (observed: 6/6 items in a review failed this way).

Fix: swap the inverted range and serve it. The response still reports Total lines, so the model can recover if the swap was not its intent. Updated TestExecute_InvalidLineRange to TestExecute_SwappedLineRange asserting the swapped range returns content.

Validation

  • go test ./internal/tool/ — pass
  • make check — pass
  • Patched binary built and run locally: ocr llm test and ocr review --commit <sha> -p work.

Disclosure

This change was developed with AI assistance (Devin / SWE-2) per the project's agent guidelines; the change was reviewed and tested before submission.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

@PrayWithYou PrayWithYou left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need CLA

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.

3 participants