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

Conversation

codegen-sh[bot]
Copy link
Contributor

@codegen-sh codegen-sh bot commented Mar 12, 2025

Description

This PR improves the error handling in the RelaceEditTool when a file is not found. Instead of raising a FileNotFoundError exception, it now returns a RelaceEditObservation with an error status and a helpful message.

Changes

  • Modified the relace_edit function to return a RelaceEditObservation with an error status when a file is not found
  • Added a more descriptive error message that includes the full filepath and suggests using the full filepath relative to the repository root

Why

Previously, when a user provided an invalid filepath to the RelaceEditTool, it would raise a FileNotFoundError exception that wasn't properly passed back to the assistant as an observation. This change ensures that file not found errors are handled consistently with other errors and returned as observations, allowing the assistant to handle them gracefully.

Fixes the issue where users would see errors like:

FileNotFoundError('File not found: codegen_agi.py')

instead of getting a helpful error message as part of the tool's observation.

@CLAassistant
Copy link

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.


codegen-bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@jayhack jayhack marked this pull request as ready for review March 12, 2025 23:33
@jayhack jayhack requested review from codegen-team and a team as code owners March 12, 2025 23:33
@jayhack jayhack merged commit a73d467 into develop Mar 12, 2025
16 of 18 checks passed
@jayhack jayhack deleted the gen/dc6365b0-006f-4d6b-aff4-306e55bd52f3 branch March 12, 2025 23:57
tkfoss pushed a commit that referenced this pull request Mar 14, 2025
## Description

This PR improves the error handling in the `RelaceEditTool` when a file
is not found. Instead of raising a `FileNotFoundError` exception, it now
returns a `RelaceEditObservation` with an error status and a helpful
message.

## Changes

- Modified the `relace_edit` function to return a
`RelaceEditObservation` with an error status when a file is not found
- Added a more descriptive error message that includes the full filepath
and suggests using the full filepath relative to the repository root

## Why

Previously, when a user provided an invalid filepath to the
`RelaceEditTool`, it would raise a `FileNotFoundError` exception that
wasn't properly passed back to the assistant as an observation. This
change ensures that file not found errors are handled consistently with
other errors and returned as observations, allowing the assistant to
handle them gracefully.

Fixes the issue where users would see errors like:
```
FileNotFoundError('File not found: codegen_agi.py')
```
instead of getting a helpful error message as part of the tool's
observation.

---------

Co-authored-by: codegen-bot <[email protected]>
Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
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.

2 participants