Skip to content

fix: thread overrideAccess into beforeChange in global update - #18675

Open
PINYOPATTANAWASANPORN wants to merge 2 commits into
payloadcms:mainfrom
PINYOPATTANAWASANPORN:fix/global-update-thread-override-access-18674
Open

PINYOPATTANAWASANPORN wants to merge 2 commits into
payloadcms:mainfrom
PINYOPATTANAWASANPORN:fix/global-update-thread-override-access-18674

Conversation

@PINYOPATTANAWASANPORN

@PINYOPATTANAWASANPORN PINYOPATTANAWASANPORN commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What?

Pass overrideAccess from the global update operation into beforeChangeArgs during field validation, establishing bit-for-bit parity with packages/payload/src/collections/operations/utilities/update.ts.

Why?

Resolves #18674.

Since 3.90, validateFilterOptions queries relationship records with overrideAccess: overrideAccess ?? false.

While the collection update utility (packages/payload/src/collections/operations/utilities/update.ts line 125) properly forwards overrideAccess into �eforeChangeArgs, the global update operation (packages/payload/src/globals/operations/update.ts lines 350–361) destructured overrideAccess from �rgs but omitted it when constructing �eforeChangeArgs.

Consequently:

  • Local API calls such as payload.updateGlobal(...) (where overrideAccess defaults to rue) had their overrideAccess flag dropped before reaching field-level hooks.
  • Inside �eforeChange, overrideAccess defaulted to undefined, causing relationship ilterOptions to execute queries with overrideAccess: false (as unauthenticated / anonymous).
  • Any global relationship targeting a collection with default access (requiring authentication) failed during Local API calls (e.g. seeds, CLI scripts, background workers) with ValidationError: The following field is invalid: .

How?

Explicitly forward overrideAccess into �eforeChangeArgs in packages/payload/src/globals/operations/update.ts:

s const beforeChangeArgs = { collection: null, context: req.context, data, doc: publicationHookDoc, docWithLocales: globalJSON, fieldsToValidate: submittedTopLevelFieldNames, global: globalConfig, operation: 'update', overrideAccess, req, skipValidation: isSavingDraft && !hasDraftValidationEnabled(globalConfig), } satisfies BeforeChangeArgs<JsonObject>

Verification & Parity

  • AST / Code Parity: Verified exact alignment with packages/payload/src/collections/operations/utilities/update.ts:
    s const beforeChangeArgs: Args<DataFromCollectionSlug<TSlug>> = { ... operation: 'update', overrideAccess, req, ... }
  • Minimal Diff: Surgical 1-line diff preserving all existing invariants and type constraints (satisfies BeforeChangeArgs).

Fixes #18674

@PINYOPATTANAWASANPORN PINYOPATTANAWASANPORN changed the title fix(payload): thread overrideAccess into beforeChange in global update (#18674) fix: thread overrideAccess into beforeChange in global update Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The global update operation now passes its overrideAccess setting to the beforeChange field hook.

Changes: Global update access propagation

Layer / File(s) Summary
Pass access override to field hooks
packages/payload/src/globals/operations/update.ts
The beforeChange field-hook arguments now include the operation’s overrideAccess setting.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: nathanlentz

Merge Risk: Minimal · up to 27540

Global updates now pass the caller's access-override setting into relationship validation, as collection updates already do. This fixes validation failures for updates made without a user when the override is set. The change is small and low risk, and nothing blocks merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change accurately: it threads overrideAccess into beforeChange in the global update operation. The raw summary confirms the single-line change in packages/payload/src/globals/opera…
Linked Issues check Passed Issue #18674 requires that the global update operation forward overrideAccess into beforeChangeArgs, matching the collection update path. The PR summary for packages/payload/src/globals/operations/upd…
Out of Scope Changes check Passed The only reported code change is one added property (overrideAccess) in the global update operation's beforeChangeArgs. This directly serves #18674. The PR summary reports no other files changed. The …
Description check Passed The description explains the change: forwarding overrideAccess from the global update operation into beforeChangeArgs so it matches the collection update path. It gives the cause (validateFilterOption…
Full details: Title check

Explanation

The title names the change accurately: it threads overrideAccess into beforeChange in the global update operation. The raw summary confirms the single-line change in packages/payload/src/globals/operations/update.ts that forwards overrideAccess into beforeChangeArgs. The title is specific and short, and it matches the linked issue #18674 objective.

Full details: Linked Issues check

Explanation

Issue #18674 requires that the global update operation forward overrideAccess into beforeChangeArgs, matching the collection update path. The PR summary for packages/payload/src/globals/operations/update.ts reports a +1/-0 change that adds overrideAccess to beforeChangeArgs. The PR description states the same change. This implements the single requirement in #18674. The issue does not request an automated test. The repository diff and file reads were unavailable, so this verdict relies on the PR summary and description, not on direct code inspection.

Full details: Out of Scope Changes check

Explanation

The only reported code change is one added property (overrideAccess) in the global update operation's beforeChangeArgs. This directly serves #18674. The PR summary reports no other files changed. The repository diff was unavailable, so the absence of other changes rests on the PR summary alone.

Full details: Description check

Explanation

The description explains the change: forwarding overrideAccess from the global update operation into beforeChangeArgs so it matches the collection update path. It gives the cause (validateFilterOptions defaulting to overrideAccess ?? false since 3.90), the affected Local API case, the exact one-line diff, and a link to the issue it fixes. It is related to the changeset and specific enough to pass.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Library detection encountered an error. Review will continue without library-specific context.

The configuration directory could not be loaded. This review used the available YAML and UI settings; directory instructions and checks were not evaluated.

Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use path_filters to narrow the review scope.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d052268 and 275407c.

Files selected for processing: 1

  • packages/payload/src/globals/operations/update.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global update drops overrideAccess, so Local API updateGlobal fails filterOptions validation (3.90 regression)

2 participants