CS-11152: fix catalog remix — resolve scoped prefixes in fetcher#4833
CS-11152: fix catalog remix — resolve scoped prefixes in fetcher#4833richardhjtan wants to merge 1 commit into
Conversation
CS-11152. Catalog remix and any authedFetch call against a card whose id is a scoped prefix form (`@cardstack/catalog/...`) was failing with 404 against `https://<origin>/@cardstack/catalog/<rest>`. The indexer rewrites instance URLs to scoped form on store, so cardIds returned from cardService propagate that form to callers like FetchCardJsonCommand → cardService.fetchJSON → network.authedFetch. VirtualNetwork.fetch already resolves scoped strings via the prefix mapping, but authedFetch funnels through fetcher first, which wrapped the string in `new Request(string)` — joining it onto document.baseURI and producing the broken URL before VirtualNetwork ever saw it. Resolve registered prefixes in fetcher prior to the Request construction, mirroring VirtualNetwork.fetch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
77a6cb0 to
3c3f7ab
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes fetcher so scoped card references are resolved before constructing a Request, preventing catalog remix and other authedFetch paths from turning @cardstack/catalog/... into an origin-relative URL.
Changes:
- Adds scoped prefix resolution to
packages/runtime-common/fetcher.ts. - Adds a regression unit test covering registered prefix resolution before
Requestconstruction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/runtime-common/fetcher.ts |
Resolves registered scoped string inputs before creating a Request. |
packages/host/tests/unit/fetcher-test.ts |
Adds coverage for scoped prefix resolution in fetcher. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Preview deploymentsHost Test Results 1 files 1 suites 1h 52m 23s ⏱️ Results for commit 3c3f7ab. Realm Server Test Results 1 files ± 0 1 suites +1 10m 6s ⏱️ + 10m 6s Results for commit 3c3f7ab. ± Comparison against earlier commit 77a6cb0. |
lukemelia
left a comment
There was a problem hiding this comment.
@backspace please check whether this approach is compatible with your cardstack/base approach
Summary
authedFetchcalls against scoped card ids (@cardstack/catalog/...) were failing with 404 onhttps://app.boxel.ai/@cardstack/catalog/<rest>.fetcher.tswraps string inputs innew Request(string)before any prefix resolution.new Requestjoins the string againstdocument.baseURI, producing the broken URL.VirtualNetwork.fetchresolves scoped strings, but it's inside the chain — everyauthedFetchcaller passes throughfetcherfirst.isRegisteredPrefix/resolveCardReference) before thenew Requeststep infetcher, mirroringVirtualNetwork.fetch.Trigger from the user's stack:
CardOrFieldListingAdapter.remix→RemixCommand→ListingInstallCommand→FetchCardJsonCommand({ cardIdentifier: sourceCard.id })wheresourceCard.idis already in scoped form because the indexer rewrites instance URLs viaunresolveResourceInstanceURLs(card-indexer.ts:81) for portability.Linear: https://linear.app/cardstack/issue/CS-11152/fail-to-remix
Test plan
Unit | fetcher > resolves a registered scoped prefix before constructing the Requestpasses (pnpm test:ember --filter "Unit | fetcher"inpackages/host).auth-error-guard-testandindex-query-engine-testpaths still pass (they constructfetcher(virtualNetwork.fetch, ...)).Before Fix - Remix failed


After Fix