[PR #17] [MERGED] fix: resolve host-relative follow-up links against the origin, not base_url #25

Closed
opened 2026-10-31 22:00:52 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-python-sdk/pull/17
Author: @sundar-svg
Created: 7/23/2026
Status: ✅ Merged
Merged: 7/27/2026
Merged by: @wei-hai

Base: main ← Head: sundar/host-relative-follow-up-links


📝 Commits (7)

  • 255429c fix: resolve host-relative follow-up links against the origin, not base_url
  • 32be4fe trim url() comment to the load-bearing why
  • eb4628b drop dated/hand-verification notes from test docstrings
  • 80c06a3 make the gateway e2e workflow model-free (core nodes only)
  • 52391bd gateway e2e: allow overriding the test workflow via COMFY_WORKFLOW_FILE
  • 5c08487 assert output dimensions, not compressed size
  • 368a360 style: apply ruff format to gateway e2e test

📊 Changes

3 files changed (+192 additions, -3 deletions)

View changed files

📝 src/comfy_low/transport.py (+7 -3)
➕ tests/integration/test_gateway_e2e.py (+140 -0)
➕ tests/test_follow_up_links.py (+45 -0)

📄 Description

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-hash → from-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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-python-sdk/pull/17 **Author:** [@sundar-svg](https://github.com/sundar-svg) **Created:** 7/23/2026 **Status:** ✅ Merged **Merged:** 7/27/2026 **Merged by:** [@wei-hai](https://github.com/wei-hai) **Base:** `main` ← **Head:** `sundar/host-relative-follow-up-links` --- ### 📝 Commits (7) - [`255429c`](https://github.com/Comfy-Org/comfy-python-sdk/commit/255429c1b2b8228f24b7cb8ff3eca1782e6d0a11) fix: resolve host-relative follow-up links against the origin, not base_url - [`32be4fe`](https://github.com/Comfy-Org/comfy-python-sdk/commit/32be4fea8ca1289657066650822ab2c695b0b09f) trim url() comment to the load-bearing why - [`eb4628b`](https://github.com/Comfy-Org/comfy-python-sdk/commit/eb4628bf923120967f046442aaf651414dfed489) drop dated/hand-verification notes from test docstrings - [`80c06a3`](https://github.com/Comfy-Org/comfy-python-sdk/commit/80c06a3b174c67ee86faebb4dd72758c0accf836) make the gateway e2e workflow model-free (core nodes only) - [`52391bd`](https://github.com/Comfy-Org/comfy-python-sdk/commit/52391bd7b5d2119176dc6e61e64d1f0dde3bec64) gateway e2e: allow overriding the test workflow via COMFY_WORKFLOW_FILE - [`5c08487`](https://github.com/Comfy-Org/comfy-python-sdk/commit/5c08487767b8c33227d18738a4030bc12eaecd1e) assert output dimensions, not compressed size - [`368a360`](https://github.com/Comfy-Org/comfy-python-sdk/commit/368a360bee0012bde7dd5e32a4b6ec6cb0b0742e) style: apply ruff format to gateway e2e test ### 📊 Changes **3 files changed** (+192 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/comfy_low/transport.py` (+7 -3) ➕ `tests/integration/test_gateway_e2e.py` (+140 -0) ➕ `tests/test_follow_up_links.py` (+45 -0) </details> ### 📄 Description ## 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-hash` → `from-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.com/claude-code) https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 22:00:52 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-python-sdk#25
No description provided.