Skip to content

SDK: UVE shows 404 for draft (non-live) pages because useEditableDotCMSPage hook does not tolerate 404 #35887

Description

@fmontes

Problem Statement

When a page is in draft state (not yet published / not live) and is opened inside the Universal Visual Editor (UVE), the headless app shows a 404 instead of rendering the draft page.

The headless client uses a read-only token and on first load requests the LIVE version of the page, which does not exist yet, so the server returns 404. The consumer app treats that 404 as an error and throws, so DotCMSLayoutBody and the useEditableDotCMSPage hook never mount / initialize.

UVE then sends the correct draft page object via postMessage (UVEEventType.CONTENT_CHANGES), but because the hook and its UVE subscription were never set up, the message never arrives and the 404 stays on screen.

Root cause: The SDK wiring — specifically the useEditableDotCMSPage hook — is not designed to accept/tolerate an error response such as a 404. Inside the UVE editing context, a 404 for a non-live page is a valid intermediate state, not a fatal error.

  • Affected file: core-web/libs/sdk/react/src/lib/next/hooks/useEditableDotCMSPage.ts
  • Type: Front-end (SDK @dotcms/react)
  • Impact: Editors cannot edit unpublished/draft pages in the Universal Visual Editor.

Steps to Reproduce

  1. Create a new page in dotCMS but do NOT publish it (leave it in draft).
  2. Open the page in the Universal Visual Editor (UVE).
  3. The headless app's first load requests the LIVE page with a read-only token and gets a 404.
  4. The app throws on the 404, so the hook never initializes; UVE's draft page object sent via postMessage is never applied.
  5. Result: A 404 is shown instead of the editable draft page.

Acceptance Criteria

  • useEditableDotCMSPage (and the SDK wiring) tolerates an initial error/404 response when running inside UVE instead of blocking initialization.
  • When a draft (unpublished) page is opened in UVE, the page renders correctly via the UVE postMessage flow instead of showing 404.
  • The UVE subscription is established even when the initial page response is an error, so the draft page object delivered by UVE is applied.
  • A 404 for a non-live page continues to behave as a real 404 outside of UVE (only treated as non-fatal when inside UVE).

dotCMS Version

Latest from main branch (SDK @dotcms/react)

Severity

High - Major functionality broken

Links

Metadata

Metadata

Type

Projects

Status
In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions