Skip to content

fix: resolve host-relative follow-up links against the origin, not base_url#17

Open
sundar-svg wants to merge 6 commits into
mainfrom
sundar/host-relative-follow-up-links
Open

fix: resolve host-relative follow-up links against the origin, not base_url#17
sundar-svg wants to merge 6 commits into
mainfrom
sundar/host-relative-follow-up-links

Conversation

@sundar-svg

Copy link
Copy Markdown

Description

First SDK↔gateway conformance bug, found (and now regression-locked) by running the SDK live against a staging serverless deployment.

The gateway serves the v2 contract under /deployment/{id}/api/v2 and returns job.urls.* follow-up links that are host-relative and already include that mount prefix — correct HTTP behavior. _Prepared.url() only recognized links starting with /api/, so a gateway self link fell into the internal-shorthand branch and got built as base_url + /api/v2 + link → double prefix → NotFound on the first poll after submit (Comfy(base_url).run(wf) submitted fine, then 404'd in Job.refresh()).

Fix: a leading-slash path containing /api/ is a server-returned link and resolves against the origin (scheme+authority) — the link is authoritative about its own path. Internal shorthand paths (/jobs/…, /assets…) still resolve under base_url + /api/v2, and Cloud / self-hosted construction is byte-identical to before (base_url == origin there). Auth attachment is unaffected (same origin).

Also adds tests/integration/test_gateway_e2e.py — an env-gated live e2e suite (skip unless COMFY_BASE_URL/COMFY_API_KEY are set) covering: multipart upload, blake3 dedup fast-path (HEAD by-hashfrom-hash), img2img submit referencing the uploaded asset by name, adaptive poll to terminal, and output download via the content redirect. The wf.set_input(node, field, asset) case is xfail: the gateway does not yet resolve core/ASSET references (gap tracked on the cloud side).

How tested

  • uv run pytest tests/ — 97 passed (92 existing + 5 new URL-resolution regression tests)
  • Live against staging gateway dep_9b63686e… (RTX 4090, SD1.5): 2 passed, 1 xfailed in 23.60s — before the fix, test_image_edit_by_name failed with NotFound: HTTP 404 on refresh

🤖 Generated with Claude Code

https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm

…se_url

A serverless gateway serves the v2 contract under /deployment/{id}/api/v2 and
returns job.urls.* links that already include that mount prefix. Resolving
them against base_url (which carries the same prefix) doubled it and 404'd
every poll after submit. Follow-up links (leading slash + containing /api/)
now resolve against scheme+authority; internal shorthand paths and Cloud /
self-hosted behavior are byte-identical to before.

Adds unit regression tests and an env-gated live integration suite
(tests/integration/test_gateway_e2e.py) that exercises upload → dedup
fast-path → img2img submit → poll → output download against a real gateway
deployment; the asset-handle case is xfail until the gateway resolves
core/ASSET references.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm
@sundar-svg
sundar-svg requested review from a team as code owners July 23, 2026 20:54
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@sundar-svg, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b8a82cb8-9e5e-4e2a-b468-8269471676ff

📥 Commits

Reviewing files that changed from the base of the PR and between 255429c and 5c08487.

📒 Files selected for processing (3)
  • src/comfy_low/transport.py
  • tests/integration/test_gateway_e2e.py
  • tests/test_follow_up_links.py

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Too big: expected string to have <=250 characters at "tone_instructions"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

The transport layer now resolves gateway follow-up URLs against the origin when needed. New tests cover URL routing and authorization, while an environment-gated integration suite exercises asset upload, deduplication, and SD1.5 image editing.

Changes

Gateway behavior

Layer / File(s) Summary
Follow-up URL resolution
src/comfy_low/transport.py, tests/test_follow_up_links.py
_Prepared resolves deployment-scoped API paths against the origin, preserves internal /api/v2 expansion, passes through absolute URLs, and retains authorization headers.
Gateway image-edit test foundation
tests/integration/test_gateway_e2e.py
Adds environment-gated configuration, deterministic PNG generation, an SD1.5 img2img workflow, and fixtures for the client and committed input asset.
Image-edit execution validation
tests/integration/test_gateway_e2e.py
Tests upload deduplication and filename-based image editing, including polling and PNG output checks; direct asset-handle input remains explicitly xfailed.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sundar/host-relative-follow-up-links
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch sundar/host-relative-follow-up-links

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/integration/test_gateway_e2e.py`:
- Line 79: Wrap the long dictionary entries in the workflow data near the
entries keyed "5" and the corresponding entry at line 96 to satisfy Ruff’s
100-character E501 limit, preserving each key, value, and nested structure
exactly.
- Around line 131-133: Remove the arbitrary 10,000-byte length assertion from
the downloaded PNG validation in the gateway test. Keep the existing PNG
signature check and replace the size requirement with a minimal non-empty
payload assertion, preserving validation that data was actually returned.
- Around line 136-140: Update the pytest.mark.xfail configuration for the
gateway reference test to use strict=True instead of strict=False, while
preserving its existing reason and expected-failure behavior.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6f85814f-fe77-4e30-823c-d2b5a62c8c8e

📥 Commits

Reviewing files that changed from the base of the PR and between 643751c and 255429c.

📒 Files selected for processing (3)
  • src/comfy_low/transport.py
  • tests/integration/test_gateway_e2e.py
  • tests/test_follow_up_links.py

Comment thread tests/integration/test_gateway_e2e.py Outdated
Comment thread tests/integration/test_gateway_e2e.py Outdated
Comment thread tests/integration/test_gateway_e2e.py
sundar-svg and others added 5 commits July 23, 2026 13:59
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm
LoadImage -> ImageInvert -> SaveImage proves the same protocol surface as
the img2img graph but runs on any deployment with nothing baked, in
seconds; drops the COMFY_CKPT_NAME knob.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm
Default stays the model-free core-node graph; an override supplies any
API-format workflow, whose first LoadImage node is rewired to the uploaded
test input.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm
An inverted gradient re-encoded with PNG row filters legitimately
compresses to ~2KB; size thresholds are encoder trivia. Match the
IHDR dimensions against the input instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants