orchestrator-core icon indicating copy to clipboard operation
orchestrator-core copied to clipboard

[Bug]: BaseModelMeta not raising NoSessionError

Open RichieB2B opened this issue 1 month ago • 1 comments

Contact Details

[email protected]

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'

RichieB2B avatar Nov 03 '25 11:11 RichieB2B

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

Mark90 avatar Nov 11 '25 09:11 Mark90