Page MenuHomePhabricator

[toolhunt-api-staging] Persistent errors when trying to update the db
Open, Needs TriagePublicBUG REPORT

Description

When not being plagued with "MySQL has gone away" issues, I began receiving the following error message when trying to run the PUT request with the staging tool:

[2023-05-21 03:35:41,032: ERROR/ForkPoolWorker-1] Task toolhunt-api.tasks.update_db[c56cb474-ebd2-4fb7-9b49-31c64d16c25e] raised unexpected: UnmappedInstanceError("Class 'builtins.NoneType' is not mapped")
Traceback (most recent call last):
  File "/data/project/toolhunt-api/www/python/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3365, in delete
    state = attributes.instance_state(instance)
AttributeError: 'NoneType' object has no attribute '_sa_instance_state'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/project/toolhunt-api/www/python/venv/lib/python3.9/site-packages/celery/app/trace.py", line 451, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/data/project/toolhunt-api/www/python/venv/lib/python3.9/site-packages/flask_celeryext/app.py", line 71, in __call__
    return Task.__call__(self, *args, **kwargs)
  File "/data/project/toolhunt-api/www/python/venv/lib/python3.9/site-packages/celery/app/trace.py", line 734, in __protected_call__
    return self.run(*args, **kwargs)
  File "/data/project/toolhunt-api-staging/www/python/src/api/async_tasks.py", line 57, in update_db
    except (exc.DBAPIError, exc.SQLAlchemyError) as err:
  File "/data/project/toolhunt-api/www/python/venv/lib/python3.9/site-packages/sqlalchemy/orm/scoping.py", line 613, in delete
    return self._proxied.delete(instance)
  File "/data/project/toolhunt-api/www/python/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3367, in delete
    raise exc.UnmappedInstanceError(instance) from err
sqlalchemy.orm.exc.UnmappedInstanceError: Class 'builtins.NoneType' is not mapped

This started when I was testing the wmhack2023 update, but does not appear to be caused by it, as the problem persisted even when I returned to an older (and presumably stable, at least once upon a time) state.

It does not occur in my Docker environment, nor on the main toolhunt tool, which suggests to me that something is fundamentally wrong with toolhunt-staging. If anyone has any thoughts, please let me know.