Skip to content

CS-11152: fix catalog remix — resolve scoped prefixes in fetcher#4833

Open
richardhjtan wants to merge 1 commit into
mainfrom
cs-11152-fail-to-remix
Open

CS-11152: fix catalog remix — resolve scoped prefixes in fetcher#4833
richardhjtan wants to merge 1 commit into
mainfrom
cs-11152-fail-to-remix

Conversation

@richardhjtan
Copy link
Copy Markdown
Contributor

@richardhjtan richardhjtan commented May 14, 2026

Summary

  • Catalog remix and other authedFetch calls against scoped card ids (@cardstack/catalog/...) were failing with 404 on https://app.boxel.ai/@cardstack/catalog/<rest>.
  • Root cause: fetcher.ts wraps string inputs in new Request(string) before any prefix resolution. new Request joins the string against document.baseURI, producing the broken URL. VirtualNetwork.fetch resolves scoped strings, but it's inside the chain — every authedFetch caller passes through fetcher first.
  • Fix: resolve registered scoped prefixes (isRegisteredPrefix / resolveCardReference) before the new Request step in fetcher, mirroring VirtualNetwork.fetch.

Trigger from the user's stack: CardOrFieldListingAdapter.remixRemixCommandListingInstallCommandFetchCardJsonCommand({ cardIdentifier: sourceCard.id }) where sourceCard.id is already in scoped form because the indexer rewrites instance URLs via unresolveResourceInstanceURLs (card-indexer.ts:81) for portability.

Linear: https://linear.app/cardstack/issue/CS-11152/fail-to-remix

Test plan

  • New unit test Unit | fetcher > resolves a registered scoped prefix before constructing the Request passes (pnpm test:ember --filter "Unit | fetcher" in packages/host).
  • Deployed reproduction (Remix on a catalog listing — Mortgage Calculator / Wine Cellar Card Definition) no longer 404s.
  • Existing fetcher unit tests still pass (no regression in URL/redirect/retry/middleware paths).
  • Existing auth-error-guard-test and index-query-engine-test paths still pass (they construct fetcher(virtualNetwork.fetch, ...)).

Before Fix - Remix failed
Screenshot 2026-05-15 at 12 34 45 AM
After Fix
Screenshot 2026-05-15 at 1 00 24 AM

@richardhjtan richardhjtan requested a review from Copilot May 14, 2026 16:43
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>
@richardhjtan richardhjtan force-pushed the cs-11152-fail-to-remix branch from 77a6cb0 to 3c3f7ab Compare May 14, 2026 16:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 Request construction.

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Preview deployments

Host Test Results

    1 files      1 suites   1h 52m 23s ⏱️
2 659 tests 2 644 ✅ 15 💤 0 ❌
2 678 runs  2 663 ✅ 15 💤 0 ❌

Results for commit 3c3f7ab.

Realm Server Test Results

    1 files  ±    0      1 suites  +1   10m 6s ⏱️ + 10m 6s
1 365 tests +1 365  1 365 ✅ +1 365  0 💤 ±0  0 ❌ ±0 
1 444 runs  +1 444  1 444 ✅ +1 444  0 💤 ±0  0 ❌ ±0 

Results for commit 3c3f7ab. ± Comparison against earlier commit 77a6cb0.

@richardhjtan richardhjtan marked this pull request as ready for review May 14, 2026 16:59
@richardhjtan richardhjtan requested review from a team May 14, 2026 16:59
Copy link
Copy Markdown
Contributor

@lukemelia lukemelia left a comment

Choose a reason for hiding this comment

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

@backspace please check whether this approach is compatible with your cardstack/base approach

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.

3 participants