Skip to content

fix(sdk): send fallbackLocale false to the REST API - #19049

Open
NgoQuocViet2001 wants to merge 1 commit into
payloadcms:mainfrom
NgoQuocViet2001:fix-sdk-fallback-locale-false
Open

NgoQuocViet2001 wants to merge 1 commit into
payloadcms:mainfrom
NgoQuocViet2001:fix-sdk-fallback-locale-false

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown

What?

fallbackLocale: false is dropped from the request URL for every SDK operation. buildSearchParams only adds fallback-locale when the value is truthy, so sdk.find({ collection: 'posts', locale: 'es', fallbackLocale: false }) requests ?locale=es instead of ?fallback-locale=false&locale=es.

Why?

The SDK option types accept false, and the REST API already treats fallback-locale=false as "no fallback". Without the param, the server falls back to the default locale when localization.fallback is enabled, so untranslated localized fields come back with default-locale content even though the caller turned fallback off.

How?

Serialize fallbackLocale when it is false too, and add a unit spec for buildSearchParams that covers a locale string and false.

  • Ran: vitest run --project unit packages/sdk/src/utilities/buildSearchParams.spec.ts. The false case fails on main (expected '?locale=es' to be '?fallback-locale=false&locale=es') and both cases pass with this change.
  • Checked: the new query string goes through sanitizeFallbackLocale as false, and ?locale=es without the option still resolves to the default locale.
  • Checked: oxfmt --check passes on both files.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between aebbf75 and 23ac093.

Files selected for processing: 2
  • packages/sdk/src/utilities/buildSearchParams.spec.ts
  • packages/sdk/src/utilities/buildSearchParams.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.

Walkthrough

buildSearchParams now includes fallbackLocale when its value is false. Tests cover string and false values in the query string.

Changes: Fallback locale query parameter

Layer / File(s) Summary
Serialize fallback locale values
packages/sdk/src/utilities/buildSearchParams.ts, packages/sdk/src/utilities/buildSearchParams.spec.ts
The parameter check now includes false. Tests expect string and false values to appear as fallback-locale, alongside locale=es.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: alessiogr

Merge Risk: Minimal · up to 23ac0

The change correctly preserves explicit fallback-locale=false behavior without identified merge-blocking risk.

Architecture risk: Low · up to 23ac0

The change affects 1 system.

Changed systems: packages/sdk

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/sdk (library) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in packages/sdk/src/utilities/buildSearchParams.spec.ts: Adds tests expecting string and false values for fallbackLocale to appear as fallback-locale in the query string, alongside locale=es.
  • observed — Modified behavior in packages/sdk/src/utilities/buildSearchParams.ts: The fallbackLocale check now includes false; previously, false values were omitted. Included values are still stringified as fallback-locale.
Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: sending fallbackLocale: false to the REST API.
Description check Passed The description directly explains the bug, its impact, the implementation, and the added test. It is related to the changeset.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant