gpt-engineer-org / gpt-engineer

Platform to experiment with the AI Software Engineer. Terminal based. NOTE: Very different from https://gptengineer.app
MIT License
52.55k stars 6.83k forks source link

Lack of error handling during file deletion in 'gpt-engineer/main.py' #225

Closed Madhav-MKNC closed 1 year ago

Madhav-MKNC commented 1 year ago

Description The code currently deletes files and subdirectories using the shutil.rmtree function when the delete_existing flag is set to True. However, it does not handle any potential errors that may occur during the deletion process. This can result in unexpected behavior or unhandled exceptions, leaving the application in an inconsistent state.

Here's a suggested approach to handle errors during deletion:

try:
    shutil.rmtree(memory_path, ignore_errors=True)
    shutil.rmtree(workspace_path, ignore_errors=True)
except Exception as e:
    # Handle the exception
    logging.error("An error occurred while deleting files: %s", str(e))
patillacode commented 1 year ago

Hi @Madhav-MKNC

Thanks for your suggestion, although for cases like this I would suggest you create a PR rather than paste the code in a comment.

Would you be interested on creating a PR with these changes? if so, here is the contributing guidelines file

Madhav-MKNC commented 1 year ago

Hey @patillacode Yes sure, I would like to submit a PR for sure.

AntonOsika commented 1 year ago

If you get an error, don't use the flag. Easy as that.