Skip to content

Hibernate Validator is enabled by default when not used#45681

Merged
vmuzikar merged 2 commits intokeycloak:mainfrom
mabartos:KC-45677
Jan 22, 2026
Merged

Hibernate Validator is enabled by default when not used#45681
vmuzikar merged 2 commits intokeycloak:mainfrom
mabartos:KC-45677

Conversation

@mabartos
Copy link
Copy Markdown
Contributor

@mabartos mabartos commented Jan 22, 2026

Screenshot From 2026-01-22 13-10-29

Closes keycloak#45677

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
@mabartos mabartos requested review from shawkins and vmuzikar January 22, 2026 12:49
@mabartos mabartos self-assigned this Jan 22, 2026
@mabartos mabartos requested review from a team as code owners January 22, 2026 12:49
error.setErrorDescription("Cannot parse the JSON");
} else if (isServerError) {
error.setErrorDescription("For more on this error consult the server log.");
} else if (throwable instanceof ValidationException) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not needed as we have the ValidationExceptionHandler.

@mabartos mabartos marked this pull request as draft January 22, 2026 12:58
vmuzikar
vmuzikar previously approved these changes Jan 22, 2026
Copy link
Copy Markdown
Contributor

@vmuzikar vmuzikar left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @mabartos.

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
@mabartos
Copy link
Copy Markdown
Contributor Author

@vmuzikar Thanks! I've just added one small change to fix Quarkus UT tests (embedded).

@mabartos mabartos marked this pull request as ready for review January 22, 2026 13:42
Copy link
Copy Markdown
Contributor

@shawkins shawkins left a comment

Choose a reason for hiding this comment

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

LGTM


@BuildStep(onlyIfNot = IsTest.class) // needed for embedded Keycloak
void disableHibernateValidatorCustomizer(BuildProducer<BuildTimeConditionBuildItem> removeBeans, CombinedIndexBuildItem index) {
if (!Profile.isFeatureEnabled(Profile.Feature.CLIENT_ADMIN_API_V2)) {
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.

Not specific to this pr, but just wanted to highlight that moving forward this type of check is going to get messy. There will be a set of features and versions where hibernate validation might be used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shawkins Once we adapt the Hibernate Validator keycloak-codebase-wide, we remove all these checks and the Hibernate Validator will be enabled by default. Right now, as it's not needed (only for experimental feature), we should not have it enabled by default as it's causing perf regressions for 26.5.x.

@vmuzikar vmuzikar merged commit 44375e2 into keycloak:main Jan 22, 2026
86 checks passed
mabartos added a commit to mabartos/keycloak that referenced this pull request Jan 22, 2026
* Hibernate Validator is enabled by default when not used

Closes keycloak#45677

Signed-off-by: Martin Bartoš <mabartos@redhat.com>

* Disable Hibernate Validator factory customizer only for non testing

Signed-off-by: Martin Bartoš <mabartos@redhat.com>

---------

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
(cherry picked from commit 44375e2)
vmuzikar pushed a commit that referenced this pull request Jan 23, 2026
)

* Hibernate Validator is enabled by default when not used

Closes #45677



* Disable Hibernate Validator factory customizer only for non testing



---------


(cherry picked from commit 44375e2)

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
edewit pushed a commit to edewit/keycloak that referenced this pull request Jan 29, 2026
* Hibernate Validator is enabled by default when not used

Closes keycloak#45677

Signed-off-by: Martin Bartoš <mabartos@redhat.com>

* Disable Hibernate Validator factory customizer only for non testing

Signed-off-by: Martin Bartoš <mabartos@redhat.com>

---------

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
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.

Hibernate Validator is enabled by default when not used

3 participants