execution: Add anti-cycle validation#13169
execution: Add anti-cycle validation#13169rattus128 wants to merge 1 commit intoComfy-Org:masterfrom
Conversation
Currently if the graph contains a cycle, the just inifitiate recursions, hits a catch all then throws a generic error against the output node that seeded the validation. Instead, fail the offending cycling mode chain and handlng it as an error in its own right.
📝 WalkthroughWalkthroughThe change adds cycle detection to the 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@execution.py`:
- Around line 793-810: The current order checks validated before visiting, which
causes cached cycle results (validated[unique_id]) to hide later back-edges and
fail to mark all nodes in overlapping cycles; change the logic in the function
that uses unique_id, visiting, and validated so that the visiting membership
test (if unique_id in visiting) runs before the cache lookup (if unique_id in
validated), compute and populate validated entries for all nodes in the detected
cycle as currently done, and only then return validated[unique_id]; ensure you
update references to visiting and validated in that function consistently so
overlapping cycles like B->C->B and B->D->B are both reported.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8b319c51-8869-40b2-990b-a0b4bd0c385f
📒 Files selected for processing (1)
execution.py
I fat fingered a cycle into a large flow without noticing tonight and it took ages to figure out what was wrong.
Currently if the graph contains a cycle, the just inifitiate recursions, hits a catch all then throws a generic error against the output node that seeded the validation. Instead, fail the offending cycling node chain and handling it as an error in its own right.
Example test case:
A workflow with a graph cycle.
Before:
After:
Regression Tests:
Firered template (I have none of the models downloaded): Errors look right:
Linux 5090, stable-cascade -> Flux2 ✅
Linux 5090, LTX2.3 FLF2V ✅