Skip to content

fix: prevent MissingGreenlet error on task board query#20

Merged
hoootan merged 1 commit intomainfrom
fix/task-board-greenlet
Apr 11, 2026
Merged

fix: prevent MissingGreenlet error on task board query#20
hoootan merged 1 commit intomainfrom
fix/task-board-greenlet

Conversation

@hoootan
Copy link
Copy Markdown
Owner

@hoootan hoootan commented Apr 11, 2026

Recursive selectin loading on sub_tasks/comments caused greenlet context loss. Changed to noload.

Change sub_tasks, comments, and parent_task relationships to
lazy="noload" to avoid recursive selectin loading that breaks
the async greenlet context. Guard to_dict() counts against
unloaded relationships.
@hoootan hoootan merged commit 8b2115f into main Apr 11, 2026
Copilot AI review requested due to automatic review settings April 11, 2026 18:15
@hoootan hoootan deleted the fix/task-board-greenlet branch April 11, 2026 18:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to eliminate SQLAlchemy async MissingGreenlet errors encountered when querying tasks for the Kanban board by preventing implicit relationship loading during serialization.

Changes:

  • Switched Task.parent_task, Task.sub_tasks, and Task.comments relationships from lazy="selectin" to lazy="noload".
  • Updated Task.to_dict() to only compute sub_tasks_count / comments_count when the relationships appear to be already loaded.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 167 to 175
parent_task: Mapped["Task | None"] = relationship(
"Task", remote_side=[id], foreign_keys=[parent_task_id]
"Task", remote_side=[id], foreign_keys=[parent_task_id], lazy="noload"
)
sub_tasks: Mapped[list["Task"]] = relationship(
"Task", foreign_keys=[parent_task_id], lazy="selectin"
"Task", foreign_keys=[parent_task_id], lazy="noload"
)
comments: Mapped[list["Comment"]] = relationship(
"Comment", back_populates="task", lazy="selectin"
"Comment", back_populates="task", lazy="noload"
)
Comment on lines +218 to +219
"sub_tasks_count": len(self.sub_tasks) if "sub_tasks" in self.__dict__ and self.sub_tasks else 0,
"comments_count": len(self.comments) if "comments" in self.__dict__ and self.comments else 0,
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