fix(tasks): eager-load version in reorder endpoint to fix MissingGreenlet
The reorder_tasks endpoint loaded RecipeTask with selectinload(subtasks) only. Serializing via TaskResponse reads RecipeTask.recipe_id, a @property that traverses the version relationship, triggering a lazy load outside the async greenlet context -> MissingGreenlet error. Add selectinload(RecipeTask.version), matching the pattern already used in the get-task flow. Fixes the previously order-dependent test_reorder_tasks failure; full suite now 179 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -223,7 +223,10 @@ async def reorder_tasks(
|
||||
result = await db.execute(
|
||||
select(RecipeTask)
|
||||
.where(RecipeTask.id.in_(data.task_ids))
|
||||
.options(selectinload(RecipeTask.subtasks))
|
||||
.options(
|
||||
selectinload(RecipeTask.subtasks),
|
||||
selectinload(RecipeTask.version),
|
||||
)
|
||||
)
|
||||
tasks_map = {t.id: t for t in result.scalars().all()}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user