Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(handler): add cycle detection to BatchUpdateIssues parent_issue_id handling (#788)

Bohan Jiangd74d7f2b7b8d
diff --git a/server/internal/handler/issue.go b/server/internal/handler/issue.go
index fb8a3ed74c..2ea94f3da7 100644
--- a/server/internal/handler/issue.go
+++ b/server/internal/handler/issue.go
@@ -1310,6 +1310,23 @@ func (h *Handler) BatchUpdateIssues(w http.ResponseWriter, r *http.Request) {
}); err != nil {
continue
}
+ // Cycle detection: walk up from the new parent to ensure we don't reach this issue.
+ cycleDetected := false
+ cursor := newParentID
+ for depth := 0; depth < 10; depth++ {
+ ancestor, err := h.Queries.GetIssue(r.Context(), cursor)
+ if err != nil || !ancestor.ParentIssueID.Valid {
+ break
+ }
+ if uuidToString(ancestor.ParentIssueID) == issueID {
+ cycleDetected = true
+ break
+ }
+ cursor = ancestor.ParentIssueID
+ }
+ if cycleDetected {
+ continue
+ }
params.ParentIssueID = newParentID
} else {
params.ParentIssueID = pgtype.UUID{Valid: false}