Skip to content

fix(server-nestjs): return the refreshed admin role list on create - #2834

Merged
shikanime merged 2 commits into
mainfrom
fix/admin-role-post-list
Oct 8, 2026
Merged

shikanime merged 2 commits into
mainfrom
fix/admin-role-post-list

Conversation

@shikanime

Copy link
Copy Markdown
Member

Pourquoi

Refs #2833

La création d'un rôle admin sur une stack où POST /api/v1/admin/roles est servie par server-nestjs (bascule nginx-strangler, cf. #2782) casse l'écran Rôles : TypeError: e.roles.filter is not a function.

Le handler NestJS répondait l'entité créée seule, alors que le legacy apps/server (createRole) répond la liste complète rafraîchie en 201 et que le client (apps/client/src/stores/admin-role.ts) affecte cette réponse à roles.value via extractData(res, 201). Le contrat ts-rest déclarait 200: AdminRoleSchema (entité seule) — en désaccord avec ses deux parties, il est la source de l'écart.

Quoi

  • Contrat : createAdminRole répond désormais 201: AdminRoleSchema.array() (packages/shared/src/contracts/admin-role.ts)
  • AdminRoleService.create (apps/server-nestjs) renvoie la liste rafraîchie des rôles après création (mapping toAdminRoles existant réutilisé)
  • Signature du contrôleur alignée ; spec de service mise à jour : verrouille la liste complète, pas l'entité seule

La position (max + 1) et l'émission adminRole.upsert sont inchangées.

Références

Related: #2833

Legacy apps/server and the client store both expect POST /api/v1/admin/roles to answer the full role array; server-nestjs answered the created entity alone, crashing the roles screen on next .filter. Align the contract (201 + array) and the NestJS handler with the legacy behavior.

Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: Ib088d8558aea8c0d73e6104a889a08ca6a6a6964
@shikanime
shikanime requested a review from a team as a code owner October 8, 2026 08:57
@shikanime shikanime self-assigned this Oct 8, 2026
@shikanime shikanime added the bug Something isn't working label Oct 8, 2026
@shikanime shikanime added this to the 9.27.0 milestone Oct 8, 2026
@shikanime
shikanime enabled auto-merge October 8, 2026 09:00
@github-actions github-actions Bot added the built label Oct 8, 2026

@StephaneTrebel StephaneTrebel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict : changements demandés. Le contrat NestJS, le service et le contrôleur sont alignés sur le tableau rafraîchi attendu par le client. Cependant, cette modification du contrat commun fait échouer le test du serveur legacy (apps/server), qui renvoie encore un objet et reçoit maintenant une 500 de validation ; la CI obligatoire est rouge et il faut résoudre cette incompatibilité sans altérer le backend gelé avant approbation.

@StephaneTrebel StephaneTrebel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Constat de CI attaché au changement de contrat.

Comment thread packages/shared/src/contracts/admin-role.ts
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: Ic50fb8d7e128232ac65cf051ada30a7e6a6a6964
@cloud-pi-native-sonarqube

Copy link
Copy Markdown

@StephaneTrebel StephaneTrebel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict : approuvée. La mise à jour corrige l’incompatibilité de test : le handler legacy renvoie bien , et sa fixture de spec reflète maintenant ce tableau sans modifier son implémentation. Le test unitaire, lint, builds, Sonar et les autres checks requis sont verts sur le head .

@StephaneTrebel StephaneTrebel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict : approuvée. La mise à jour corrige l’incompatibilité de test : le handler legacy createRole renvoie bien listRoles(), et sa fixture de spec reflète maintenant ce tableau sans modifier son implémentation. Le test unitaire, lint, builds, Sonar et les autres checks requis sont verts sur le head bd69cbdf.

@shikanime
shikanime disabled auto-merge October 8, 2026 09:25
@shikanime
shikanime added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit 0b40912 Oct 8, 2026
34 checks passed
@shikanime
shikanime deleted the fix/admin-role-post-list branch October 8, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working built

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [BUG] - Création de rôle admin : le crash client e.roles.filter suit la réponse NestJS (entité seule) au lieu de la liste legacy

2 participants