fix(generate): fetch spec from /openapi not /openapi.yml (BE-2982)#517
fix(generate): fetch spec from /openapi not /openapi.yml (BE-2982)#517mattmillerai wants to merge 2 commits into
Conversation
comfy-api serves the OpenAPI spec at /openapi (JSON, valid YAML); the old /openapi.yml path 404s, so `comfy generate refresh` always failed and exited 1. Point _refresh() at /openapi. The JSON body is written verbatim to the cache and parsed by load_raw_spec() with yaml.load (JSON is a YAML subset), so no further change is needed. Adds a regression test asserting _refresh() requests <base_url>/openapi.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 26 seconds 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 3 finding(s).
| Severity | Count |
|---|---|
| 🟠 High | 1 |
| 🟢 Low | 2 |
Panel: 6/8 reviewers contributed findings.
Reviewers that did not contribute: kimi-k2.5:adversarial (empty), kimi-k2.5:edge-case (empty)
Harden the newly-activated `/openapi` refresh path per cursor-review: - Refuse to cache a non-spec 200. `_refresh()` follows redirects and caches the body verbatim for 7 days; an HTML interstitial / redirect landing page / JSON array or scalar would poison the cache and crash every `generate` subcommand (`.get()` on a non-mapping) until the TTL expired. Add `spec.validate_spec_text()` requiring a dict shaped like an OpenAPI doc, and gate `write_cache()` on it. - Parse JSON exponent floats. The remote serves JSON, where `json.dumps` emits point-less signed exponents (`1e+16`, `1e-07`) that PyYAML's YAML 1.1 float resolver treats as strings. Add a resolver for that form. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ELI-5
comfy generate refreshdownloads the latest list of API models. It wasknocking on the wrong door —
/openapi.yml— which the server answers with"404 Not Found", so the command always failed and exited 1. The spec actually
lives at
/openapi(served as JSON). This changes the one URL so the dooropens.
What changed
comfy_cli/command/generate/app.py—_refresh()now fetches<base_url>/openapiinstead of<base_url>/openapi.yml._refresh()requests<base_url>/openapi.Nothing else needed changing: the server returns JSON, and JSON is a subset of
YAML, so
write_cache()(verbatim write) +load_raw_spec()(yaml.load)parse it fine.
base_url(), the vendored spec, and the/proxy/allowlist areuntouched.
Why it's safe
base_url()rstrips the trailing slash, so the URL resolves tohttps://api.comfy.org/openapi._refresh()is the only spec-fetch call site (grepped — all otheropenapi.ymlreferences are file paths: the bundled spec and the~/.comfy/openapi-cache.ymlcache filename).Verification (live, 2026-07-14)
GET https://api.comfy.org/openapi→ 200; body parses as YAML,openapi: 3.0.2,servers: [{url: https://api.comfy.org}](matches thevendored spec so
base_url()resolves identically), 314 paths.GET https://api.comfy.org/openapi.yml→ 404.ruff format --check+ruff checkclean.Notes
reading
base_url()after refresh repopulates thelru_cached spec fromthe freshly-written minimal tmp cache, which leaked into later tests. The
test now resolves the expected URL before invoking refresh.