Repository navigation
feat(core): support searching users by custom data - #9793
Merged
Merged
Conversation
Add a repeatable `customData` query parameter to `GET /api/users` that matches `users.custom_data` with JSONB containment (`@>`). Values within one object are combined with AND, repeated parameters with OR, and other user filters with AND. The feature is guarded by `isDevFeaturesEnabled`. Add a GIN index for custom data containment lookups and document the new parameter in OpenAPI. Amp-Thread-ID: https://ampcode.com/threads/T-01a1570d-dbc7-707d-9f3d-cdda9406fd02
Remove the dev feature gate so the repeatable `customData` filter on `GET /api/users` is available by default, and add a changeset for the new Management API capability. Amp-Thread-ID: https://ampcode.com/threads/T-01a1570d-dbc7-707d-9f3d-cdda9406fd02
simeng-li
reviewed
Oct 20, 2026
simeng-li
reviewed
Oct 20, 2026
simeng-li
reviewed
Oct 20, 2026
simeng-li
reviewed
Oct 20, 2026
PostgreSQL row-level security prevents non-leakproof JSONB containment from using a GIN index, so the users_custom_data_gin index did not help tenant-scoped queries. Remove the index and its alteration; custom data lookups should be combined with other selective filters. Amp-Thread-ID: https://ampcode.com/threads/T-01a1570d-dbc7-707d-9f3d-cdda9406fd02
Limit repeated `customData` query values to 20 so a single request cannot add an unbounded number of JSONB containment checks to every scanned user row. Map PostgreSQL error codes `22P05` (unsupported Unicode escape sequence) and `22003` (numeric overflow) to `request.invalid_input`, since raw JSON text that passes `JSON.parse` can still be rejected by the JSONB cast.
simeng-li
approved these changes
Oct 21, 2026
gao-sun
reviewed
Oct 22, 2026
gao-sun
reviewed
Oct 22, 2026
Replace `qq` with `customId` in the OpenAPI description, examples, and the parameter hint, and simplify the changeset summary.
gao-sun
approved these changes
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #8550.
Add a repeatable
customDataquery parameter toGET /api/usersfor exact user lookup by user custom data.Each value is a JSON object and is matched with
users.custom_data @> value::jsonb. Matching is type-strict, supports nested objects and arrays, treatsnullas an explicit value, and rejects empty objects/arrays. Keys within one object are ANDed, repeatedcustomDataparameters are ORed, and the filter is combined with existing user filters using AND. Raw JSON text is passed to PostgreSQL to preserve large integers.Also updates the OpenAPI definition and adds unit/integration coverage.
Custom data filtering is not backed by a GIN index: PostgreSQL row-level security prevents the non-leakproof JSONB containment operator from using one. Combine
customDatawith other selective filters for large user sets. Docs: logto-io/docs#1520.Testing
Tested locally
Checklist
.changeset