feat: comfy templates check — per-template runnable/missing/api-required verdict#557
feat: comfy templates check — per-template runnable/missing/api-required verdict#557mattmillerai wants to merge 2 commits into
Conversation
…red verdict (BE-3376)
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @mattmillerai.
Found 9 finding(s).
| Severity | Count |
|---|---|
| 🟠 High | 1 |
| 🟡 Medium | 2 |
| 🟢 Low | 6 |
Panel: 6/8 reviewers contributed findings.
Reviewers that did not contribute: kimi-k2.5:adversarial (empty), kimi-k2.5:edge-case (empty)
Address the 9 review-panel findings on `comfy templates check`: - HIGH: URL-encode the (untrusted) template name in the workflow cache path, matching _fetch_template_workflow, so a gallery entry with `../` or path separators can't traverse outside gallery/templates. - MED: guard _iter_workflow_nodes against truthy non-dict `definitions` and non-list `nodes`/subgraph-`nodes` (valid JSON that previously raised AttributeError/TypeError past the JSONDecodeError catch). - MED: normalize BOTH sides of the model presence match with _basename so a required name carrying a subfolder (SDXL/model.safetensors) still matches a basename folder listing. - LOW: coerce requiresCustomNodes via _as_str_list (a bare string no longer splits into per-char entries). - LOW: catch UnicodeDecodeError alongside JSONDecodeError when parsing workflow bytes (check + fetch). - LOW: write the workflow cache atomically (temp + os.replace) so an interrupted write can't wedge future non-refresh runs. - LOW: only attribute api `source` to object_info when it actually found API nodes; an empty scan leaves the index heuristic as the source. - LOW: rich.markup.escape untrusted values in pretty output. - LOW: drop model requirements with an empty name (unmatchable; would report a phantom empty-name missing model). Adds 8 tests covering the hardened paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Pushed 45b0e2e addressing all 9 cursor-review panel findings (path-traversal in the workflow cache path, malformed-workflow type guards, both-sided basename matching, Note on the two red checks — both are pre-existing repo-wide infra breaks, not from this PR (which only touches
|
ELI-5
comfy templates ls/show/fetchlet you browse the workflow-template gallery, but none of them answer the practical question: "if I run this template right now on my machine, will it actually work?" This addscomfy templates check <name>— a per-template verdict for THIS install.It fetches the template's workflow, figures out which model files it needs, and checks which of those you already have downloaded locally. It also tells you whether the template needs a paid partner-API (like a Flux/Kling API node) and lists any custom nodes it declares. You get one of four verdicts:
runnable— every model it needs is present (or it needs no models and nothing looks like a loader).missing-models— some model files aren't downloaded; the output table lists each with its download URL.api-required— it depends on a partner-API node, so it won't run purely locally.unknown— it has loader-ish nodes but declares no models, so we genuinely can't tell.What it does
comfy templates check <name> [--gallery <path>] [--refresh]:<name>against the gallery index (sametemplate_not_found+close_matchesaffordance asfetch).<XDG cache>/comfy-cli/gallery/templates/<name>.json(reused unless--refresh).nodesanddefinitions.subgraphs[*].nodes, gathering everyproperties.modelsentry{name, directory, url}, deduped by(directory, name). The subgraph walk is mandatory — modern templates (e.g.image_z_image_turbo) carry their models only inside subgraphs.api_*name orAPItag), and (b) if a local server is reachable,object_infois loaded and any workflow node whose class hasapi_node: trueis flagged. The payload records which tier answered (api.source=index|object_info)./models/<folder>listings, matching by basename (listings can include subdirectories). A 404 folder (custom-node folders likeSEEDVR2) → those files reported missing + a warning; server unreachable → structuredserver_not_runningerror hintingcomfy launch.custom_nodes_requiredverbatim from the index (report-only in v1 — install state not verified).JSON envelope:
{name, title, verdict, models: {required, present, missing:[{name,directory,url}]}, api:{dependent,source,api_nodes}, custom_nodes_required, warnings}. Pretty mode prints a ✓/✗ line plus a table of missing files with their download URLs.Tests
tests/comfy_cli/command/test_templates.pygains: workflow-walker unit tests (top-level models, subgraph-only models,(directory,name)dedupe, basename helper, subgraph-interior class-type collection) and the full verdict matrix with mocked folder listings +object_info(all-present → runnable, one-missing → missing-models, 404 folder → missing+warning, api-required via index and via object_info, zero-models+no-loaders → runnable, zero-models+loader → unknown, subfoldered basename match, server-down →server_not_running, unknown template, custom-nodes passthrough). Fulltests/comfy_cli/command+tests/comfy_cli/outputsuites pass;ruff format/checkclean; new emitted command registered indiscovery.py.Self-review notes
gallery_load_failed,template_not_found,template_fetch_failed,template_workflow_invalid_json, andserver_not_running, so the error-code registry test stays green.server_not_runningmirrors the existingmodelscommands and carries an actionablecomfy launchhint. The falsification trigger does not apply.models.requiredis emitted as a count (present/missing are the lists); a non-runnableverdict still exits 0 with the verdict in the payload (per the ticket'semit(...)spec — the verdict is the signal, not the exit code);_flatten_templatesgains an additiverequires_custom_nodesfield (also now visible intemplates show's envelope).🤖 Generated with Claude Code