Skip to content

fix(rest): parse where param in parseParams#15745

Open
hugomeduarte wants to merge 1 commit intopayloadcms:mainfrom
hugomeduarte:fix/parse-where-param-in-parseParams
Open

fix(rest): parse where param in parseParams#15745
hugomeduarte wants to merge 1 commit intopayloadcms:mainfrom
hugomeduarte:fix/parse-where-param-in-parseParams

Conversation

@hugomeduarte
Copy link

What?

Parse the where query parameter when it is sent as a JSON string in REST API requests (e.g. ?where={"read":{"equals":false}}), so that the filter is applied correctly. When where is already an object (e.g. from bracket notation like the Admin uses), it is left unchanged.

Why?

In GET requests, all query parameters are strings. When the client sends where as a JSON string, parseParams did not parse it, so find (and count, delete, etc.) operations received a string instead of an object and the filter was not applied. The same pattern already exists for the data parameter; this adds the same for where.

How?

In parseParams, after the data block: if where is present and is a string, run JSON.parse(params.where) and assign the result to parsedParams.where. When where is already an object (e.g. from bracket notation), the condition is false and we do nothing, so existing behavior is preserved. Added tests for the string case, the object passthrough case, and invalid JSON (expect throw).

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

Pull Request titles must follow the Conventional Commits specification and have valid scopes.

Unknown scope "rest" found in pull request title "fix(rest): parse where param in parseParams". Scope must match one of: cpa, claude, db-*, db-d1-sqlite, db-mongodb, db-postgres, db-vercel-postgres, db-sqlite, db-d1-sqlite, drizzle, email-*, email-nodemailer, email-resend, eslint, graphql, kv, kv-redis, live-preview, live-preview-react, live-preview-vue, next, payload-cloud, plugin-cloud, plugin-cloud-storage, plugin-ecommerce, plugin-form-builder, plugin-import-export, plugin-mcp, plugin-multi-tenant, plugin-nested-docs, plugin-redirects, plugin-search, plugin-sentry, plugin-seo, plugin-stripe, richtext-*, richtext-lexical, richtext-slate, sdk, storage-*, storage-azure, storage-gcs, storage-r2, storage-uploadthing, storage-vercel-blob, storage-s3, translations, ui, templates, examples(/(\w|-)+)?, deps.

feat(ui): add Button component
^    ^    ^
|    |    |__ Subject
|    |_______ Scope
|____________ Type

@hugomeduarte hugomeduarte changed the title parse where param in parseParams fix: parse where param in parseParams Feb 24, 2026
@hugomeduarte hugomeduarte changed the title fix: parse where param in parseParams fix(rest): parse where param in parseParams Feb 24, 2026
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