Skip to content

fix: resolve host-relative follow-up links against the origin, not baseUrl#21

Merged
sundar-svg merged 1 commit into
mainfrom
sundar/host-relative-follow-up-links
Jul 24, 2026
Merged

fix: resolve host-relative follow-up links against the origin, not baseUrl#21
sundar-svg merged 1 commit into
mainfrom
sundar/host-relative-follow-up-links

Conversation

@sundar-svg

Copy link
Copy Markdown
Contributor

Description

TypeScript mirror of Comfy-Org/ComfyPythonSDK#17 — the same bug existed verbatim in urlFor (src/low/transport.ts).

The serverless 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. urlFor only recognized links starting with /api/, so a gateway self link fell into the internal-shorthand branch and was built as baseUrl + /api/v2 + link → double prefix → 404 on the first poll after submit.

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

The resolution rule is being pinned in the contract itself: Comfy-Org/cloud#5498 documents it on the JobUrls schema.

How tested

  • pnpm test — 134 passed (130 existing + 4 new resolution/auth regression tests in src/low/followUpLinks.test.ts, driven through a capturing fetch so the full request path is exercised)
  • pnpm lint, pnpm typecheck clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm

…seUrl

Mirrors ComfyPythonSDK#17: a serverless gateway serves the v2 contract
under /deployment/{id}/api/v2 and returns job.urls.* links that already
include that mount prefix; joining them to baseUrl doubled the prefix and
404'd every poll after submit. Server links (leading slash + containing
/api/) now resolve against scheme+authority; internal shorthand paths and
Cloud / self-hosted behavior are byte-identical to before.

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 22:13
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ee955765-dc9b-4bc8-a537-13d96de250b8

📥 Commits

Reviewing files that changed from the base of the PR and between 3716a17 and 684168e.

📒 Files selected for processing (2)
  • src/low/followUpLinks.test.ts
  • src/low/transport.ts

📝 Walkthrough

Walkthrough

Changes

Follow-up Link URL Resolution

Layer / File(s) Summary
Mounted link resolution and validation
src/low/transport.ts, src/low/followUpLinks.test.ts
ComfyLow.urlFor resolves server paths containing /api/ against the origin of baseUrl, while tests verify gateway prefixes, shorthand paths, bare-surface links, and authorization headers.

Suggested reviewers: wei-hai

🚥 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 requested a review from wei-hai July 23, 2026 22:14
@sundar-svg
sundar-svg merged commit 5f12f4b into main Jul 24, 2026
7 checks passed
@sundar-svg
sundar-svg deleted the sundar/host-relative-follow-up-links branch July 24, 2026 00:10
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