Skip to content

handleStaleDataCheck drops the incoming request, so access functions that read headers or cookies refuse it and the "Document modified" warning never shows #19981

Backlog

Description

@kilichakan2

Describe the Bug

handleStaleDataCheck (packages/ui/src/utilities/handleStaleDataCheck.ts) calls req.payload.findByID / req.payload.findGlobal with overrideAccess: false, user: req.user but without req. The Local API then builds a fresh request with empty headers (createLocalReq), so any read access function that looks at the incoming request's cookies or headers (for example a second-factor check stored in a cookie) returns false. executeAccess throws Forbidden, the check logs Error checking for stale data: Forbidden You are not allowed to perform this action., and returns isStale: false, so DocumentStaleData never shows.

The same request passed canAccessAdmin moments earlier in buildFormStateHandler, so it is only the dropped req that fails.

Link to the code that can reproduce this issue

(none public: a minimal repro below)

Reproduction Steps

  1. A collection or global whose read access returns Boolean(req.user) && req.headers.get('cookie')?.includes('mark=1').
  2. Sign in and set the mark=1 cookie; open an existing document's edit view in two tabs.
  3. Save in tab 1; type in tab 2.
  4. Expected: the "Document modified" modal in tab 2. Actual: no modal; the server logs Error checking for stale data: Forbidden ….

Fix

Pass the incoming request instead of only its user, in both branches:

-        user: req.user
+        req

We run this as a local patch on @payloadcms/ui 3.93.0 with a database test; the warning shows and no error is logged. 3.94.2 and main (read 2026-11-26) have the same call.

Which area(s) are affected?

area: ui

Environment Info

Payload 3.93.0 (@payloadcms/ui 3.93.0), Next.js 16.4.5, Node 24, @payloadcms/db-postgres.

Activity

  1. added
    area: ui
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPayload OSSarea: ui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions