Skip to content

Record the ID of a new organization group in its create admin event - #55210

Open
shuseng8 wants to merge 1 commit into
keycloak:mainfrom
shuseng8:issue-55123
Open

shuseng8 wants to merge 1 commit into
keycloak:mainfrom
shuseng8:issue-55123

Conversation

@shuseng8

Copy link
Copy Markdown

Closes #55123

The admin event recorded when a top-level organization group is created now has the resource path organizations/<orgId>/groups/<groupId> instead of organizations/<orgId>/groups. This matches realm groups, where GroupsResource records the create event as groups/<groupId>. With the ID in the path, the event can be found under the group's own path, for example in its "Admin events" tab.

Changes:

  • OrganizationGroupsResource#addTopLevelGroup uses resourcePath(uri, group.getId()) for CREATE. Moving an existing group to the top level (UPDATE) still records the request path, like realm groups do.
  • Tests in OrganizationGroupsTest assert the CREATE event (operation, resource type, path with the group ID, and representation with the ID and name) and the unchanged path of the move-to-top-level UPDATE event. The CREATE test fails without the fix.
  • Added a note under Notable changes in changes-27_0_0.adoc. As described in the issue, events recorded before the upgrade are not migrated.

Not changed: creating a subgroup through OrganizationGroupResource#addSubGroup still records organizations/<orgId>/groups/<parentId>/children. This is the same as realm subgroups (groups/<parentId>/children in GroupResource#addChild), so I kept this PR limited to the case in the issue. Happy to change both in a follow-up if you'd like.

Tests run locally (embedded server):

  • org.keycloak.tests.organization.group.*Test: 83 tests, all passed
  • org.keycloak.tests.organization.**, AdminEventTest and org.keycloak.tests.admin.group.*Test: 560 tests, all passed
  • ./mvnw -Pspotless spotless:check passed on services and tests/base

AI assistance: An AI agent was used to help implement this change. I reviewed the code and tests and take responsibility for the contribution.

Closes keycloak#55123

Signed-off-by: Shubham <87247136+shuseng8@users.noreply.github.com>
@shuseng8
shuseng8 requested a review from a team as a code owner November 15, 2026 09:37
Copilot AI balanced review requested due to automatic review settings November 15, 2026 09:37

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

No active review issues are reported for the change to include the new group’s ID in organization group creation events.

No open issues 🎉

What changed in this PR

Fixes #55123 by including the new group’s ID in top-level organization group creation events, allowing those events to appear in the group’s Admin events tab.

Changes:

  • Records the group-specific path for CREATE events while preserving the collection path for UPDATE events.
  • Adds regression tests for both event paths and the creation event’s representation.
  • Documents the change and clarifies that historical events remain unchanged.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​organization/​group/​OrganizationGroupsTest.java Tests creation and move-to-top-level admin events.
services/​src/​main/​java/​org/​keycloak/​organization/​admin/​resource/​OrganizationGroupsResource.java Includes the new group ID in the creation event path.
docs/​documentation/​upgrading/​topics/​changes/​changes-27_0_0.adoc Explains the new event path and implications for existing filters.

Review effort: Balanced

@jamesconwaydev jamesconwaydev left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. Read only, didn't run it.

Compared it with GroupsResource#addTopLevelGroup on main: the realm version sets resourcePath(uri) on the move branch and resourcePath(uri, child.getId()) on the create branch, then calls representation(rep).success() once after. This PR gives OrganizationGroupsResource exactly that shape, and rep.setId(group.getId()) was already there before the event, so the representation in the CREATE event carries the ID the new test asserts.

Written with help from an AI assistant (Claude Code); each reference was checked against the source.

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.

Create event of organization group is recorded without the group id

3 participants