Pythagora-io / gpt-pilot

The first real AI developer
Other
29.08k stars 2.91k forks source link

Remove files crash #950

Closed senko closed 1 month ago

senko commented 1 month ago

This fixes an error in which a file gets removed but still remains in state files list and crashing when Pythagora tries to handle it:

The second commit is some small related cleanup, so best to review commit by commit.

2024-05-24 15:21:26,606 DEBUG [core.state.state_manager] File routes/stripeWebhookRoutes.js was removed from workspace, deleting from project
2024-05-24 15:21:26,606 INFO [core.agents.orchestrator] Removed files from project: routes/stripeWebhookRoutes.js
2024-05-24 15:21:26,606 DEBUG [core.agents.orchestrator] Committing imported files as a separate step 282
2024-05-24 15:21:26,608 DEBUG [core.db.session] Connected to database sqlite+aiosqlite:///pythagora.db
sys:1: SAWarning: Object of type <File> not in session, add operation along 'ProjectState.files' will not proceed
2024-05-24 15:21:26,640 ERROR [core.cli.main] Uncaught exception: 'NoneType' object has no attribute 'content'
Traceback (most recent call last):
  File "/home/senko/Projects/Pythagora/gpt-pilot/core/cli/main.py", line 37, in run_project
    success = await orca.run()
              ^^^^^^^^^^^^^^^^
  File "/home/senko/Projects/Pythagora/gpt-pilot/core/agents/orchestrator.py", line 64, in run
    await self.update_stats()
  File "/home/senko/Projects/Pythagora/gpt-pilot/core/agents/orchestrator.py", line 326, in update_stats
    total_lines += len(file.content.content.splitlines())
                       ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'content'