Skip to content

Ignore empty entries in org domain list#423

Open
vilmosnagy wants to merge 2 commits intop2-inc:mainfrom
vilmosnagy:403-ignore-empty-entries-in-org-domain-list
Open

Ignore empty entries in org domain list#423
vilmosnagy wants to merge 2 commits intop2-inc:mainfrom
vilmosnagy:403-ignore-empty-entries-in-org-domain-list

Conversation

@vilmosnagy
Copy link
Contributor

Closes #403

private String url;

@JsonProperty("domains")
@JsonDeserialize(contentUsing = EmptyStringAsNullDeserializer.class)
Copy link
Member

Choose a reason for hiding this comment

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

Does anyone remember why there are domains in the attributes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two tests in OrganizationImportTest broke without this at some point, 'cause to my understanding the OrganizationsResource::importOrgs method parses the request's body eventually to this POJO.

But if I remove these two lines, no tests break at the moment. Give me a little time to understand better, if the annotations in the class io.phasetwo.service.representation.Organization are enough, or we really need these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Give me a little time to understand better, if the annotations in the class io.phasetwo.service.representation.Organization are enough, or we really need these.

I think we do need them on the OrganizationAttributes class. When the annotation is not present, it seems that an empty string gets persisted to the database, but is later filtered out when the data is returned via the API. I need to think a bit about how we can best write tests to cover this behavior.

Related to that filtering - do we mind that after this change the API behavior will change slightly? Already saved empty strings will no longer be returned in the domain list. I don’t think it’s a problem, because if someone queries and saves the org representation, the empty strings would be removed anyway. With this API change, the difference on the UI should be minimal: users won’t see the empty strings even before saving.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the annotation is not present, it seems that an empty string gets persisted to the database, but is later filtered out when the data is returned via the API.

This is indeed the case. I added a new test class, OrganizationImportWithDatabaseAccessTest, which starts a Keycloak instance backed by a PostgreSQL Testcontainers database. The test asserts that no empty strings are persisted to the ORGANIZATION_DOMAIN table.

If the two newly added annotations are removed from the OrganizationAttributes class, the OrganizationImportWithDatabaseAccessTest test fails, demonstrating the issue.

@vilmosnagy vilmosnagy marked this pull request as draft February 5, 2026 16:09
@vilmosnagy vilmosnagy force-pushed the 403-ignore-empty-entries-in-org-domain-list branch from 579b0b1 to ae819d6 Compare February 6, 2026 09:07
@vilmosnagy vilmosnagy marked this pull request as ready for review February 6, 2026 09:08
@vilmosnagy vilmosnagy force-pushed the 403-ignore-empty-entries-in-org-domain-list branch from cda695a to f0f27f4 Compare February 17, 2026 17:35
@rtufisi rtufisi requested a review from xgp February 20, 2026 07:58
@vilmosnagy vilmosnagy force-pushed the 403-ignore-empty-entries-in-org-domain-list branch from f0f27f4 to ec69421 Compare February 20, 2026 14:59
@github-actions
Copy link

Code Coverage

Overall Project 26.23%
Files changed 100% 🍏

File Coverage
EmptyStringAsNullDeserializer.java 100% 🍏
Organization.java 34.53% 🍏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore empty entries in org domain list

2 participants