Skip to content

fix(server-nestjs): resolve Keycloak root group by path, not name - #2604

Merged
StephaneTrebel merged 1 commit into
mainfrom
fix/server-nestjs-keycloak-root-group-path
Aug 26, 2026
Merged

fix(server-nestjs): resolve Keycloak root group by path, not name#2604
StephaneTrebel merged 1 commit into
mainfrom
fix/server-nestjs-keycloak-root-group-path

Conversation

@shikanime

Copy link
Copy Markdown
Member

Issues liées

Closes #2518


Comportement actuel

Lors de l'ajout d'un repo d'infrastructure, l'événement project.upsert déclenche KeycloakService.syncProject -> getOrCreateGroupByPath('/<slug>'). Deux défauts dans KeycloakClientService :

  1. getRootGroupByName : le fallback ?? candidates.find(g => g.name === name) sur groups.find({ search }) (recherche par sous-chaîne à toutes les profondeurs) peut retourner un sous-groupe à un autre chemin (ex. /console/other/myproject) au lieu du groupe racine /<slug>.
  2. getOrCreateGroupByPath : le segment racine appelait getGroupByName (recherche large par nom) au lieu de getRootGroupByName (recherche par path).

L'ID de groupe erroné alimente ensuite getGroupMembers -> listMembers -> Keycloak répond « Could not find group by id ».

Nouveau comportement

  1. getRootGroupByName ne match plus que par path exact /<name> (groupes racine uniquement) — suppression du fallback par nom.
  2. getOrCreateGroupByPath utilise getRootGroupByName pour le segment racine avant création.

2 tests unitaires couvrent : réutilisation du groupe racine existant (match par path malgré un sous-groupe au mauvais chemin de même nom), et création du groupe racine quand seule une sous-groupe au mauvais chemin correspond.

Breaking change

Non.

Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I54908a3c7c0c03cd7798968b14816c946a6a6964
@shikanime
shikanime requested a review from a team as a code owner August 26, 2026 14:14
@shikanime shikanime self-assigned this Aug 26, 2026
@shikanime shikanime added the bug Something isn't working label Aug 26, 2026
@github-actions github-actions Bot added built and removed bug Something isn't working labels Aug 26, 2026
@shikanime shikanime added this to the 9.24.5 milestone Aug 26, 2026
@cloud-pi-native-sonarqube

Copy link
Copy Markdown

@StephaneTrebel
StephaneTrebel added this pull request to the merge queue Aug 26, 2026
Merged via the queue into main with commit 3fdb90b Aug 26, 2026
35 checks passed
@StephaneTrebel
StephaneTrebel deleted the fix/server-nestjs-keycloak-root-group-path branch August 26, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [BUG] - Keycloak : "Could not find group by id" sur l'ajout d'un repo d'infra

2 participants