Skip to content

Correcting SCIM filter - #55059

Open
hypery2k wants to merge 2 commits into
keycloak:mainfrom
m13tLabs:bugfix/scim-filter
Open

hypery2k wants to merge 2 commits into
keycloak:mainfrom
m13tLabs:bugfix/scim-filter

Conversation

@hypery2k

Copy link
Copy Markdown
Contributor

resolves #53260

@hypery2k
hypery2k requested a review from a team as a code owner November 11, 2026 17:59
Copilot AI balanced review requested due to automatic review settings November 11, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The scalar comparison can select a value inconsistent with serialization and ignores longValue storage, causing filters to incorrectly exclude users with multiple stored values or attributes longer than 255 characters.

2 open issues
What changed in this PR

This PR addresses #53260 by aligning missing-value behavior for single-valued SCIM user attributes with direct entity fields.

Changes:

  • Uses correlated scalar subqueries for single-valued collection-backed attributes while retaining EXISTS for multivalued attributes.
  • Adds regression tests for comparison, negation, and presence filters.
  • Documents single-valued and multivalued negation semantics.
File Description
scim/​tests/​base/​src/​test/​java/​org/​keycloak/​tests/​scim/​tck/​FilterTest.java Tests missing-value semantics for standard and custom single-valued attributes.
scim/​model/​src/​main/​java/​org/​keycloak/​scim/​model/​filter/​ScimJPAPredicateProvider.java Adds scalar subqueries for single-valued attribute filtering.
docs/​documentation/​server_admin/​topics/​scim/​filtering-resources.adoc Explains missing-value behavior under negated comparisons.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 11, 2026 18:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Long-value comparisons remain inconsistent: attr ne "Engineer" excludes a user that not (attr eq "Engineer") includes because comparisons do not account for LONG_VALUE.

1 open issue
2 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 12, 2026 09:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The documentation must qualify negated-filter behavior for collection-backed attributes and clarify that not (emails eq "x") still excludes users without an email.

2 open issues

Review effort: Balanced

Comment on lines +85 to +88
For a single-valued attribute, the negated comparison `not (attribute eq "value")` behaves like `attribute ne "value"`
and also does not match resources where the attribute has no value. For a multi-valued attribute,
`not (attribute eq "value")` matches resources that do not have the given value, including resources where the
attribute has no value.
resolves keycloak#53260

Signed-off-by: Martin Reinhardt <martin@m13t.de>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 10:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A length check produces incorrect case-insensitive eq and ne results for values with identical lowercase hashes but different original lengths.

4 open issues

Review effort: Balanced

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Martin Reinhardt <martin@m13t.de>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 10:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the SCIM filtering changes.

1 open issue
3 resolved since last review

Review effort: Balanced

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.

SCIM filter: ne and not (attr eq ...) produce inconsistent null semantics for single-valued user-profile attributes

2 participants