Fix substring bug in dependency tree cycle detection (#159)
* Add .worktrees/ to .gitignore Prevents git worktree contents from being tracked in the repository. * Fix substring bug in dependency tree cycle detection The cycle detection in GetDependencyTree() was using a simple substring match which incorrectly flagged valid nodes as cycles. For example, "bd-1" would be blocked because "bd-10" contains "bd-1" as a substring. This bug affects any beads project where issue IDs contain each other as substrings (BD-1/BD-10, ISSUE-1/ISSUE-10, etc). Changed from: AND t.path NOT LIKE '%' || i.id || '%' To delimiter-aware checks that respect the → separator: AND t.path != i.id AND t.path NOT LIKE i.id || '→%' AND t.path NOT LIKE '%→' || i.id || '→%' AND t.path NOT LIKE '%→' || i.id This ensures we only match complete issue IDs, not substrings. Added TestGetDependencyTree_SubstringBug to demonstrate and prevent regression of this issue. The test creates a chain from bd-10 to bd-1 and verifies all nodes appear in the dependency tree. Discovered while testing dependency tree visualization with bd-1/bd-10.
This commit is contained in:
@@ -496,7 +496,10 @@ func (s *SQLiteStorage) GetDependencyTree(ctx context.Context, issueID string, m
|
||||
JOIN dependencies d ON i.id = d.depends_on_id
|
||||
JOIN tree t ON d.issue_id = t.id
|
||||
WHERE t.depth < ?
|
||||
AND t.path NOT LIKE '%' || i.id || '%'
|
||||
AND t.path != i.id
|
||||
AND t.path NOT LIKE i.id || '→%'
|
||||
AND t.path NOT LIKE '%→' || i.id || '→%'
|
||||
AND t.path NOT LIKE '%→' || i.id
|
||||
)
|
||||
SELECT id, title, status, priority, description, design,
|
||||
acceptance_criteria, notes, issue_type, assignee,
|
||||
|
||||
Reference in New Issue
Block a user