Skip to content

Improve RelaceEditTool error handling for file not found errors #826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/codegen/extensions/tools/relace_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ def relace_edit(codebase: Codebase, filepath: str, edit_snippet: str, api_key: O
try:
file = codebase.get_file(filepath)
except ValueError:
msg = f"File not found: {filepath}"
raise FileNotFoundError(msg)
# Return an observation with error status instead of raising an exception
# Include the full filepath in the error message
return RelaceEditObservation(
status="error",
error=f"File not found: {filepath}. Please provide the full filepath relative to the repository root.",
filepath=filepath,
)

# Get the original content
original_content = file.content
Expand Down
Loading