From ddac662ce355c67ed3703bb9fc6a82f6344da14a Mon Sep 17 00:00:00 2001 From: Daniel Moerner Date: Mon, 23 Nov 2026 18:44:59 -0500 Subject: [PATCH 1/2] docs(backend): Correct the negate and match docs on UserSearchMetadataFilter A negated `equals` filter matches only users that hold the key with a different value, and `equals` matches any item when the key holds an array. Co-Authored-By: Claude Fable 5.2 --- .changeset/user-search-filter-negate-docs.md | 5 +++++ packages/backend/src/api/endpoints/UserApi.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/user-search-filter-negate-docs.md diff --git a/.changeset/user-search-filter-negate-docs.md b/.changeset/user-search-filter-negate-docs.md new file mode 100644 index 00000000000..41ded8f59ae --- /dev/null +++ b/.changeset/user-search-filter-negate-docs.md @@ -0,0 +1,5 @@ +--- +'@clerk/backend': patch +--- + +Correct the `UserSearchMetadataFilter` JSDoc. A negated `equals` filter matches users that hold the key with a different value, not every user the filter does not match, and `equals` matches any item when the key holds an array. diff --git a/packages/backend/src/api/endpoints/UserApi.ts b/packages/backend/src/api/endpoints/UserApi.ts index 97627e5b7c2..5ece1b9a34a 100644 --- a/packages/backend/src/api/endpoints/UserApi.ts +++ b/packages/backend/src/api/endpoints/UserApi.ts @@ -99,11 +99,11 @@ export type UserSearchMetadataFilter = { scope: 'public' | 'private' | 'unsafe'; /** A dot-separated path into the metadata, for example `settings.theme`. Escape a literal dot in a key as `\.`. */ key: string; - /** `exists` matches users that hold the key, whether it holds a value or nested keys. `equals` matches the whole value, case-insensitively. */ + /** `exists` matches users that hold the key, whether it holds a value or nested keys. `equals` matches the whole value, case-insensitively. If the key holds an array, `equals` matches any item in it. */ match: 'exists' | 'equals'; /** The value to compare against. Required for `equals` and not allowed for `exists`. */ value?: string; - /** If `true`, returns the users the filter does not match instead. */ + /** If `true`, inverts the filter. A negated `exists` matches users that do not hold the key. A negated `equals` matches users that hold the key with a different value. */ negate?: boolean; }; From 3d08364e8a837a81d6b148c27e1477a803e7eff4 Mon Sep 17 00:00:00 2001 From: Daniel Moerner Date: Mon, 23 Nov 2026 19:27:24 -0500 Subject: [PATCH 2/2] docs(backend): Describe negate per match type A negated `equals` is not an inversion, since it still requires the key. Say what `negate` does for each match type. Co-Authored-By: Claude Fable 5.2 --- packages/backend/src/api/endpoints/UserApi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/api/endpoints/UserApi.ts b/packages/backend/src/api/endpoints/UserApi.ts index 5ece1b9a34a..dca9ccd6a44 100644 --- a/packages/backend/src/api/endpoints/UserApi.ts +++ b/packages/backend/src/api/endpoints/UserApi.ts @@ -103,7 +103,7 @@ export type UserSearchMetadataFilter = { match: 'exists' | 'equals'; /** The value to compare against. Required for `equals` and not allowed for `exists`. */ value?: string; - /** If `true`, inverts the filter. A negated `exists` matches users that do not hold the key. A negated `equals` matches users that hold the key with a different value. */ + /** If `true`, `exists` matches users that do not hold the key, and `equals` matches users that hold the key with a different value. */ negate?: boolean; };