-
Notifications
You must be signed in to change notification settings - Fork 10
Description
-
Summary:
The _viewcode method in project.py raises an IndexError when the AI agent requests a line range larger than the file. -
Steps to Reproduce:
Call _viewcode on a file with N lines where endline - startline > N
Example: file has 50 lines, agent calls viewcode(ref, path, startline=1, endline=100) -
Expected behavior:
The method should clamp the range to the file's actual line count and return whatever lines are available without crashing. -
Actual Behavior:
Crashes with"Backporting exited with code 1: else self.func(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vsts/work/1/a/backporting-workspace/patch-backporting/src/tools/project.py\", line 777, in viewcode\n return project._viewcode(ref, path, startline, endline)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vsts/work/1/a/backporting-workspace/patch-backporting/src/tools/project.py\", line 114, in _viewcode\n ret.append(lines[i])\n ~~~~~^^^\nIndexError: list index out of range\n", -
Impact:
Causes the entire backporting job to fail
The agent cannot recover since the tool crashes rather than returning a useful message
Likely triggered frequently on small files where the agent guesses a large line range