8000 Include organization definitions in the partial export by Hakaou · Pull Request #54274 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Include organization definitions in the partial export - #54274

Merged
pedroigor merged 1 commit into
keycloak:mainfrom
Hakaou:39334-partial-export-organizations
Oct 26, 2026
Merged

pedroigor merged 1 commit into
keycloak:mainfrom
Hakaou:39334-partial-export-organizations

Conversation

@Hakaou
@Hakaou Hakaou commented Oct 22, 2026 •
Copy link
Copy Markdown
Contributor

Follow-up to the discussion in #39334 with @vramik.

The partial export (partial-export, used by the Admin Console export) skipped the organizations as a whole in ExportUtils. Since 26.8 the domain routing lives on the organization domains, so the exported file carried no trace of it.

Changes:

  • ExportUtils.exportRealm() exports the organizations for partial exports too, with the same representation as the full export. Only the members, with their organization group memberships, stay limited to the full export.
  • Identity providers at the realm level are still exported without organization links. The links stay inside each organization, as in the full export.
  • No new switch in the export dialog. Organizations are included whenever the feature is enabled, as proposed in Organizations are not present in JSON realm export #39334.
  • OrganizationExportTest.testPartialExport checks, for each combination of exportClients and exportGroupsAndRoles: name, alias, description and attributes, the domain with its identity provider routing, the identity provider link (organization id, autoMembership set to false before the export, membership type), the organization group, no members, and realm-level identity providers without links. It then posts the whole exported JSON to partialImport with ifResourceExists=SKIP added and expects 200. The partial import dialog of the console sends only the selected resource lists. The partial import accepts the file and does not restore the organizations: PartialImportRepresentation has no organizations field and ignores unknown properties.
  • importExport.adoc: organizations are exported without their members, and the Admin Console partial import does not import them.

Tests run locally on f7532e1 with JDK 21:

Run Result
OrganizationExportTest with the change (embedded Undertow) 3 run, 0 failures, 0 errors 8000 , 0 skipped. testExport covers the full export with members. testExportImportEmptyOrg covers an organization without members.
Same, with ExportUtils reverted to main testPartialExport fails at assertThat(export.getOrganizations(), hasSize(1)): Expected: a collection with size <1> but: was null
New test framework, embedded server: PartialExportTest, PartialImport*Test, ExportImportTest, RealmImportSharedUndefinedClientRoleTest 72 run, 0 failures, 0 errors, 0 skipped
spotless:check on both changed modules clean

Related work:

AI usage: I designed and directed this change and reviewed every line. An AI agent (Claude) wrote the code and the test under my direction, from the discussion in #39334. The change was verified locally before opening the PR. I can explain and revise the code myself.

Closes #39334

The partial export skipped the organizations as a whole. Since 26.8 the
domain routing lives on the organization domains, so the exported file
carried no trace of it.

The organizations are now exported with the same representation as in
the full export. Members stay limited to the full export. Identity
providers at the realm level are still exported without organization
links. The partial import accepts the file and does not import the
organizations.

Closes keycloak#39334

Signed-off-by: Hakaou <hakaou@fr.scc.com>
@Hakaou
Hakaou requested review from a team as code owners October 22, 2026 19:51
Copilot AI balanced review requested due to automatic review settings October 22, 2026 19: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.

🟢 Approval recommended

The focused change preserves full-export behavior, includes targeted regression coverage and documentation, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

Addresses #39334 by including organization definitions and domain routing in Admin Console partial exports, while keeping organization members limited to full exports.

Changes:

  • Includes organization definitions in partial exports without changing full-export behavior.
  • Expands regression coverage across all export-option combinations and checks that partial import accepts the exported JSON.
  • Documents that partial exports omit organization members and partial imports do not restore organizations.
File Description
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​organization/​exportimport/​OrganizationExportTest.java Verifies organization data, omitted members, identity-provider links, and partial-import acceptance.
model/​storage-private/​src/​main/​java/​org/​keycloak/​exportimport/​util/​ExportUtils.java Includes organizations in partial exports while restricting members to full exports.
docs/​guides/​server/​importExport.adoc Clarifies organization export and partial-import limitations.

Review effort: Balanced

@sguilhen sguilhen 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.

If I understood the issue correctly, this is the first step (partial export), with the counterpart (partial import) coming as a separate PR.

In this context, I think the PR is well structured and properly tested. Approving.

@pedroigor
pedroigor merged commit 43aa9d9 into keycloak:main Oct 26, 2026
98 checks passed
@pedroigor
Copy link
Copy Markdown
Contributor

Thanks, @Hakaou.

@Hakaou
Hakaou deleted the 39334-partial-export-organizations branch October 26, 2026 12:27
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.

Organizations are not present in JSON realm export

4 participants

0