gpt-pilot icon indicating copy to clipboard operation
gpt-pilot copied to clipboard

[BUG]: Error while checking for existing project triggers TypeError while showing the error to the user.

Open Miscend opened this issue 1 year ago • 3 comments

I'm on Win 11. Using default sqlite database. I get this error consistently whenever I try to continue a previous project:

---------- GPT PILOT EXITING WITH ERROR ----------
Traceback (most recent call last):
  File "O:\GPT Pilot Projects\gpt-pilot\pilot-env\lib\site-packages\peewee.py", line 7136, in get     
    return clone.execute(database)[0]
  File "O:\GPT Pilot Projects\gpt-pilot\pilot-env\lib\site-packages\peewee.py", line 4486, in __getitem__
    return self.row_cache[item]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "O:\GPT Pilot Projects\gpt-pilot\pilot\database\database.py", line 192, in get_app
    app = App.get(App.id == app_id)
  File "O:\GPT Pilot Projects\gpt-pilot\pilot-env\lib\site-packages\peewee.py", line 6688, in get     
    return sq.get()
  File "O:\GPT Pilot Projects\gpt-pilot\pilot-env\lib\site-packages\peewee.py", line 7139, in get     
    raise self.model.DoesNotExist('%s instance matching query does '
database.models.app.AppDoesNotExist: <Model: App> instance matching query does not exist:
SQL: SELECT "t1"."id", "t1"."created_at", "t1"."updated_at", "t1"."user_id", "t1"."app_type", "t1"."name", "t1"."status" FROM "app" AS "t1" WHERE ("t1"."id" = ?) LIMIT ? OFFSET ?
Params: ['1ecd7a2db285455bbefd7ee44e56ed29', 1, 0]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "O:\GPT Pilot Projects\gpt-pilot\pilot\main.py", line 45, in <module>
    args = init()
  File "O:\GPT Pilot Projects\gpt-pilot\pilot\main.py", line 31, in init
    arguments = get_arguments()
  File "O:\GPT Pilot Projects\gpt-pilot\pilot\utils\arguments.py", line 50, in get_arguments
    app = get_app(arguments['app_id'])
  File "O:\GPT Pilot Projects\gpt-pilot\pilot\database\database.py", line 196, in get_app
    raise ValueError(f"No app with id: {app_id}")
ValueError: No app with id: 1ecd7a2d-b285-455b-befd-7ee44e56ed29
--------------------------------------------------
Traceback (most recent call last):
  File "O:\GPT Pilot Projects\gpt-pilot\pilot\main.py", line 88, in <module>
    exit_gpt_pilot(project, ask_feedback)
  File "O:\GPT Pilot Projects\gpt-pilot\pilot\utils\exit.py", line 115, in exit_gpt_pilot
    print('Exit', type='exit')
TypeError: 'type' is an invalid keyword argument for print()

Miscend avatar Dec 24 '23 01:12 Miscend

The error happens here:

https://github.com/Pythagora-io/gpt-pilot/blob/a1fb2afadd53ad94914476d519939da5aa2f2ef2/pilot/main.py#L45

which is before we monkey-patch builtin print() with message type args.

The exit-prompt code called here:

https://github.com/Pythagora-io/gpt-pilot/blob/a1fb2afadd53ad94914476d519939da5aa2f2ef2/pilot/utils/exit.py#L115

...then tries to use the message type which fails.

The best thing would be to not monkeypatch builtins. The second best thing would be to monkeypatch it before doing database open. The third thing would be to refactor the big try/except clause in main and handle the cases differently.

senko avatar Dec 26 '23 16:12 senko

@Miscend this crashes the app although it shouldn't have to, but what you're probably interested here is the fact that it doesn't find the previous project in the database (it cannot find the app with id 1ecd7a2db285455bbefd7ee44e56ed29).

This might be because the database was deleted in the meantime (eg. if you've run db_init.py), or if the app ID is incorrect for some other reason.

senko avatar Dec 26 '23 16:12 senko

does this issue persist ?

techjeylabs avatar Apr 24 '24 14:04 techjeylabs