You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7920321
Browse filesBrowse the repository at this point in the historyBrowse files
SQLA: Replace the deprecated lazy="noload" with lazy="raise"
SQLAlchemy 2.1 deprecated the `noload` lazy loading strategy
(sqlalchemy/sqlalchemy#11045). `noload` silently returns `None`/empty
collections — essentially incorrect results — and will be removed in a
future release.
This PR replaces all 5 occurrences of `lazy="noload"` with `lazy="raise"`,
which raises `InvalidRequestError` if the relationship is accessed without
an explicit eager load (e.g. `joinedload`). All affected relationships are
already properly loaded via `joinedload()` wherever they're accessed, so
this is a safe drop-in that also catches missing eager loads at development
time instead of silently returning `None`.
Two callers needed fixes to work correctly with `lazy="raise"`:
- `TaskInstance.rendered_task_instance_fields` and `TaskInstance.hitl_detail`
needed `passive_deletes=True` to tell SQLAlchemy to rely on the DB-level
`ON DELETE CASCADE` rather than attempting ORM-level cascade processing
(which would fail since FK columns are also PK columns on RTIF, and
`lazy="raise"` prevents the ORM from loading the collection to clear them).
- The HITL API endpoints needed `joinedload(TI.rendered_task_instance_fields)`
added to their queries, since `TaskInstanceResponse` accesses
`rendered_task_instance_fields` during Pydantic serialization. The
`get_hitl_detail` endpoint also needed an explicit `model_validate()` call
so serialization happens while the session is still active.
**Changed models:**
- `Log.task_instance`
- `TaskInstance.rendered_task_instance_fields`
- `TaskInstance.hitl_detail`
- `TaskInstanceHistory.hitl_detail`
- `XComModel.task`
related: apache#61229
0 commit comments