orchestrator-core
orchestrator-core copied to clipboard
[Bug]: BaseModelMeta not raising NoSessionError
Contact Details
What happened?
The purpose of BaseModelMeta is to raise NoSessionError when the database session has not been initialized. However, that is not what happens. Instead an AttributeError about _query is thrown instead.
Version
4.5.3
What python version are you seeing the problem on?
Python 3.12
Relevant log output
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/app/src/services.py", line 412, in resolve_subscription_process
SubscriptionTable.query.join(SubscriptionInstanceTable)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/app/venv/lib/python3.12/site-packages/orchestrator/db/database.py", line 55, in query
if self._query is not None:
^^^^^^^^^^^
AttributeError: type object 'SubscriptionTable' has no attribute '_query'
Good spot. Personally it's one of those errors I've just gotten accustomed to seeing and knowing that it means I forgot to setup the database connection. But it would be nice to improve this; probably using getattr and letting the error message say that init_database() hasn't been executed yet