Skip to content

Add missing fields to prevent SQLAlchemy error - #99

Merged
AlexCXC merged 1 commit into
mainfrom
add-missing-fields
Aug 4, 2026
Merged

AlexCXC merged 1 commit into
mainfrom
add-missing-fields

Conversation

@simonhammes

@simonhammes simonhammes commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

The /admin/runs endpoint of the python-scheduler returns HTTP 500 since ScriptLog.to_dict() tries to access fields that were not included inside the SQL query.

This was the error:

[2026-08-04 09:06:10,143] [ERROR] flask_server app.py:875 log_exception Exception on /admin/runs/ [GET] Traceback (most recent call last):
  File /root/.local/lib/python3.12/site-packages/flask/app.py, line 1511, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/flask/app.py, line 919, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/flask/app.py, line 917, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/flask/app.py, line 902, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /opt/scheduler/flask_server.py, line 460, in list_runs
    runs = [r.to_dict(include_context_data=False, include_output=False) for r in runs]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /opt/scheduler/faas_scheduler/models.py, line 76, in to_dict
    state: self.state,
             ^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py, line 569, in __get__
    return self.impl.get(state, dict_)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py, line 1096, in get
    value = self._fire_loader_callables(state, key, passive)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py, line 1129, in _fire_loader_callables
    return callable_(state, passive)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/strategies.py, line 578, in __call__
    return strategy._load_for_state(state, passive)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/strategies.py, line 536, in _load_for_state
    raise orm_exc.DetachedInstanceError(
sqlalchemy.orm.exc.DetachedInstanceError: Parent instance <ScriptLog at 0x7f366da33200> is not bound to a Session; deferred load operation of attribute 'state' cannot proceed (Background on this error at: https://sqlalche.me/e/20/bhk3)

This was the error:

[2026-08-04 09:06:10,143] [ERROR] flask_server app.py:875 log_exception Exception on /admin/runs/ [GET]
Traceback (most recent call last):
  File /root/.local/lib/python3.12/site-packages/flask/app.py, line 1511, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/flask/app.py, line 919, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/flask/app.py, line 917, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/flask/app.py, line 902, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /opt/scheduler/flask_server.py, line 460, in list_runs
    runs = [r.to_dict(include_context_data=False, include_output=False) for r in runs]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /opt/scheduler/faas_scheduler/models.py, line 76, in to_dict
    state: self.state,
             ^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py, line 569, in __get__
    return self.impl.get(state, dict_)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py, line 1096, in get
    value = self._fire_loader_callables(state, key, passive)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py, line 1129, in _fire_loader_callables
    return callable_(state, passive)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/strategies.py, line 578, in __call__
    return strategy._load_for_state(state, passive)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /root/.local/lib/python3.12/site-packages/sqlalchemy/orm/strategies.py, line 536, in _load_for_state
    raise orm_exc.DetachedInstanceError(
sqlalchemy.orm.exc.DetachedInstanceError: Parent instance <ScriptLog at 0x7f366da33200> is not bound to a Session; deferred load operation of attribute 'state' cannot proceed (Background on this error at: https://sqlalche.me/e/20/bhk3)
@AlexCXC
AlexCXC merged commit d9263c8 into main Aug 4, 2026
2 checks passed
@simonhammes
simonhammes deleted the add-missing-fields branch August 4, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants