Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid live updates subscription detected" error if entry contains circular entry reference - REST API #847

Open
dndrsn opened this issue Aug 21, 2024 · 2 comments

Comments

@dndrsn
Copy link

dndrsn commented Aug 21, 2024

Describe the bug

ContentfulLivePreview.subscribe (and useContentfulLiveUpdates) return the following error when attempting to subscribe to a REST API entry that contains a circular reference.

 [Live Preview]: Invalid live updates subscription detected.
            Please keep in mind that the data provided to the live updates needs to have "sys.id", "fields" for REST or the "__typename" for GraphQL on the data structure.

The data object provided is not transformed and does have both sys.id and fields properties as can been seen in the error message itself:

image

This issue may be a problem with the CMS console endpoint that handles the subscription requests, not this codebase.

To Reproduce
Steps to reproduce the behavior:

  1. Create a content model with a reference field.
  2. Create two entries using the model, each with references to the other.
  3. Create a web page that uses useContentfulLiveUpdates or ContentfulLivePreview.subscribe to subscribe to the REST data for one of those entries
  4. Open page within live preview
  5. Change content data -> data does not update in live preview frame
  6. View browser log. Notice warning noted above.

Expected behavior
No console warning. Live update to data on page in live preview frame.

Context (please complete the following information):

  • Live preview SDK version number: 4.5.3
  • REST / GraphQL API: REST
  • Next 14 using app router
@dndrsn dndrsn changed the title "Invalid live updates subscription detected" Error using REST data "Invalid live updates subscription detected" error if the same entry ID is encountered more than once. Aug 22, 2024
@dndrsn dndrsn changed the title "Invalid live updates subscription detected" error if the same entry ID is encountered more than once. useContentfulLiveUpdates "Invalid live updates subscription detected" error - REST API Aug 22, 2024
@dndrsn
Copy link
Author

dndrsn commented Aug 23, 2024

On further investigation, useContentfulLiveUpdates and ContentfulLivePreview.subscribe return the error if the entry being subscribed to contains a circular reference. For example if an entry has a reference to another entry and that entry has a reference to the original entry. The reference can be via a reference(s) type field or via a entry link within a rich text field.

Updating the issue title and description updated (again).

@dndrsn dndrsn changed the title useContentfulLiveUpdates "Invalid live updates subscription detected" error - REST API "Invalid live updates subscription detected" error if entry contains circular entry reference - REST API Aug 23, 2024
@chrishelgert
Copy link
Contributor

👋
Hey, thanks for bringing this up - we will have a look 👀

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

No branches or pull requests

2 participants