Skip to content

Fix cross-realm linksTo MIME type handling for file/image defs#4400

Draft
lucaslyl wants to merge 2 commits intomainfrom
CS-10730/card-thumbnail-linksto-imagedeffiledef-fails-to-save-for-cross-realm
Draft

Fix cross-realm linksTo MIME type handling for file/image defs#4400
lucaslyl wants to merge 2 commits intomainfrom
CS-10730/card-thumbnail-linksto-imagedeffiledef-fails-to-save-for-cross-realm

Conversation

@lucaslyl
Copy link
Copy Markdown
Contributor

linear: https://linear.app/cardstack/issue/CS-10730/card-thumbnail-linksto-imagedeffiledef-fails-to-save-for-cross-realm

Previously, cross-realm linksTo requests for file-def and image-def could send an incorrect Accept header and fail with 415 Unsupported Media Type.(from console)
image

Changes:

  1. In loadLinks, use expectsCard as the primary signal for cross-realm links.
  2. If expectsCard is true, fetch with card MIME type.
  3. Otherwise, fetch with file-meta MIME type.
  4. Remove the card-only isSingleCardDocument assertion from this mixed cross-realm path to avoid false failures on valid file-meta responses.

Result:

Cross-realm file-def/image-def links resolve correctly.
Eliminates 415 errors caused by wrong media type negotiation.

Screen.Recording.2026-04-14.at.6.56.06.PM.mov

@lucaslyl lucaslyl self-assigned this Apr 14, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f1b20f4c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

});
let response: Response;

if(expectsCard){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Default unknown cross-realm links to card MIME

When relationship.data.type is omitted (a valid/stale case already handled above), expectsCard stays false unless the type is explicitly card. In this cross-realm branch that means we now send Accept: application/vnd.card.file-meta+json by default, while the in-realm branch still defaults unknown types to card lookup. As a result, cross-realm card links with missing data.type can negotiate the wrong representation (or fail with media-type errors), causing linked card relationships to stop resolving correctly.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown

Realm Server Test Results

  1 files  ±0    1 suites  ±0   14m 8s ⏱️ +21s
845 tests +1  845 ✅ +1  0 💤 ±0  0 ❌ ±0 
916 runs  +1  916 ✅ +1  0 💤 ±0  0 ❌ ±0 

Results for commit e06f743. ± Comparison against base commit 72d1f10.

@github-actions
Copy link
Copy Markdown

Host Test Results

    1 files  ±0      1 suites  ±0   2h 29m 37s ⏱️ - 4m 5s
2 194 tests ±0  2 151 ✅  - 28  15 💤 ±0   0 ❌ ± 0  28 🔥 +28 
2 194 runs  ±0  2 123 ✅  - 56  15 💤 ±0  28 ❌ +28  28 🔥 +28 

For more details on these errors, see this check.

Results for commit e06f743. ± Comparison against base commit 72d1f10.

@lucaslyl lucaslyl marked this pull request as draft April 14, 2026 13:12
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.

1 participant