Fix organization creation when domain is empty - #50857
Conversation
Signed-off-by: ayush <ishusingh1404@gmail.com>
There was a problem hiding this comment.
Pull request overview
Fixes organization creation when the optional domain field is empty.
Changes:
- Filters blank domains before API conversion.
- Allows blank input in shared domain validation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
Organizations.java |
Treats blank domains as absent. |
OrganizationForm.tsx |
Excludes blank domains from requests. |
|
|
||
| public static void validateDomain(String rawDomain) { | ||
| if (rawDomain == null) { | ||
| if (rawDomain == null || isBlank(rawDomain)) { |
| domains: org.domains | ||
| ?.filter((d) => d.trim() !== "") | ||
| .map((d) => ({ name: d, verified: false })), |
|
|
||
| public static void validateDomain(String rawDomain) { | ||
| if (rawDomain == null) { | ||
| if (rawDomain == null || isBlank(rawDomain)) { |
|
|
||
| public static void validateDomain(String rawDomain) { | ||
| if (rawDomain == null) { | ||
| if (rawDomain == null || isBlank(rawDomain)) { |
| domains: org.domains | ||
| ?.filter((d) => d.trim() !== "") | ||
| .map((d) => ({ name: d, verified: false })), |
|
@ayushmanayush All the suggestions from Copilot appear to be valid. Please fix them before we proceed with further review. |
|
Ok I'll further look into it and update asap |
| domains: org.domains | ||
| ?.filter((d) => d.trim() !== "") | ||
| .map((d) => ({ name: d, verified: false })), |
|
@ayushmanayush We need you to sign your commits so that DCO will pass. |
Signed-off-by: ayush <ishusingh1404@gmail.com>
|
I think all commits need to be signed-off for the DCO check to pass. So either add the sign-off or, better yet, squash them into one |
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.oauth.ClientAuthPostMethodTest#testPostAuthenticationNotAllowedWhenBasicRequestedorg.keycloak.testsuite.oauth.ClientAuthPostMethodTest#testBasicAuthenticationNotAllowedWhenPostRequestedorg.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRequiredActionKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRefreshInTab1Keycloak CI - Forms IT (chrome) |
@sguilhen - ideally yes. Still, the last commit is signed off, and we might proceed with that if no-one objects. I approved the build, the frontend has some problems. @ayushmanayush - can you please review those? |
|
there is also a prettier problem in |
|
Thanks for the contribution @ayushmanayush! Since this has been idle for a while and it is a fix for a regression, I went ahead and opened a new PR with the necessary adjustments so we can get it merged. The main changes from the original PR:
Closing in favor of #51542. |
Description
Fixes the regression introduced in 26.7.0 where creating an organization
without specifying a domain results in an "Invalid domain format" error.
Root cause
The frontend converted empty domain values into domain objects, causing
validation to fail even though the domain field is optional.
Solution
Filter out empty domain values before creating the domain objects so that
validation is only applied to non-empty domains.
Fixes #50825