Skip to content

fix(rich-text-versioning): pin react-query v4 to fix editor load crash []#11048

Open
david-shibley-contentful wants to merge 1 commit into
masterfrom
fix/rich-text-versioning-editor-sys-crash
Open

fix(rich-text-versioning): pin react-query v4 to fix editor load crash []#11048
david-shibley-contentful wants to merge 1 commit into
masterfrom
fix/rich-text-versioning-editor-sys-crash

Conversation

@david-shibley-contentful

Copy link
Copy Markdown
Contributor

Summary

  • Pin @tanstack/react-query@4.44.0 as a direct dependency so Vite bundles v4 instead of hoisting v5 from @contentful/field-editor-shared
  • Fixes Cannot read properties of undefined (reading 'sys') when loading the rich text editor on fields with embedded entry/asset references
  • Harden the version comparison dialog against missing link targets and fix stale state when fetching content types for embedded entries

Root cause

With react-query v5 hoisted, FetchingWrappedInlineEntryCard in @contentful/field-editor-rich-text@6.3.9 does not treat 'pending' as a loading state. The success branch renders before entity data is available and accesses entry.sys.

Test plan

  • npm run build passes in apps/rich-text-versioning
  • npm test passes (32 tests)
  • Manual: open an entry with embedded inline/block entry references — editor loads without console errors
  • Manual: Compare versions dialog renders embedded references correctly

Made with Cursor

Vite was hoisting @tanstack/react-query v5 from field-editor-shared, which
left FetchingWrappedInlineEntryCard treating in-flight fetches as success and
reading entry.sys before data loaded. Pin v4 at the app level so embedded
reference cards use loading status correctly.

Also harden the version comparison dialog against missing link targets and fix
stale state when fetching content types for embedded entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@david-shibley-contentful david-shibley-contentful requested review from a team as code owners July 1, 2026 21:44
if (contentTypeIds.length > 0) {
const fetchedContentTypes = await sdk.cma.contentType.getMany({
query: {
'sys.id[in]': contentTypeIds.join(','),

@joaquincasal Joaquin (joaquincasal) Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just in case: this is changing from an array to a comma-separated string, but I'd expect either work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call. Either should work with the CMA client. I used .join(',') here to match getEntries / getAssets in this file, not because the array form was failing.

The meaningful change in this block is using the freshly fetched entries (instead of stale state), deduping IDs, and guarding missing contentType refs. Happy to switch back to passing the array if you prefer consistency with the old line rather than with the other queries in Dialog.tsx.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need! As long as the CMA accepts both, it's good

@david-shibley-contentful david-shibley-contentful changed the title fix(rich-text-versioning): pin react-query v4 to fix editor load crash fix(rich-text-versioning): pin react-query v4 to fix editor load crash [] Jul 2, 2026
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