E251 Reject non-integer display order when creating or updating a client scope by kccrcodes · Pull Request #55824 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Reject non-integer display order when creating or updating a client scope - #55824

Open
kccrcodes wants to merge 1 commit into
keycloak:mainfrom
kccrcodes:fix/55731-gui-order-validation
Open

kccrcodes wants to merge 1 commit into
keycloak:mainfrom
kccrcodes:fix/55731-gui-order-validation

Conversation

@kccrcodes
@kccrcodes kccrcodes commented Dec 5, 2026 •
Copy link
Copy Markdown

Closes #55731

The Admin REST API now returns 400 for a non-integer gui.order on client scope create and update, using the same integer rule OrderedModel already applies when sorting.

Decisions and assumptions:

  • A blank value stays valid because the persistence layer treats it as "not set", and that is what the Admin Console sends when the field is cleared.
  • Negative values are still accepted. The Admin Console limits the field with min=0, but the server never did; happy to change this.
  • No Admin Console change. The number input already can't send a non-numeric value.

Tests: new cases in tests/base ClientScopeTest fail before the change (expected 400 but was 201) and pass after; ClientScopeTest, ParameterizedClientScopeTest, ClientScopeProtocolMapperTest and ClientScopeEvaluateTest pass (63 tests).

This change was written with the help of Grok Build. I reviewed it and ran the tests locally.

…cope

The display order of a client scope is stored in the gui.order attribute
and is read as an integer when scopes are sorted, but the Admin REST API
stored any string. A value such as "abc" was then listed in the Admin
Console while the settings form showed the field as empty.
Return a 400 Bad Request when the value is not an integer. A blank value
is still accepted because it means that the display order is not set.

Closes keycloak#55731

Signed-off-by: Kalent Chia <kccrcodes@users.noreply.github.com>
@kccrcodes
kccrcodes marked this pull request as ready for review December 5, 2026 08:51
@kccrcodes
kccrcodes requested a review from a team as a code owner December 5, 2026 08:51
Copilot AI balanced review requested due to automatic review settings December 5, 2026 08:51
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 validation allows Unicode whitespace that the persistence layer does not treat as blank, causing non-integer attribute values to be stored.

1 open issue
What changed in this PR

Adds server-side validation for client-scope display order, addressing #55731 through the Admin REST API.

Changes:

  • Rejects non-integer gui.order values on create and update.
  • Preserves acceptance of blank values and negative integers.
  • Adds regression tests for rejection, unchanged stored values, and clearing display order.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​admin/​client/​ClientScopeTest.java Adds display-order validation tests.
services/​src/​main/​java/​org/​keycloak/​services/​resources/​admin/​ClientScopesResource.java Validates display order during creation.
services/​src/​main/​java/​org/​keycloak/​services/​resources/​admin/​ClientScopeResource.java Implements shared validation and applies it during updates.

Review effort: Balanced

return;
}
String guiOrder = clientScope.getAttributes().get(ClientScopeModel.GUI_ORDER);
if (guiOrder == null || guiOrder.isBlank()) {
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.

Client scope "Display order" (gui.order) accepts non-integer values via the Admin API

2 participants

0