Skip to content

fix(server-nestjs): make GitLab CI variable provisioning idempotent - #2617

Open
shikanime wants to merge 3 commits into
mainfrom
fix/gitlab-ci-variable-idempotent
Open

fix(server-nestjs): make GitLab CI variable provisioning idempotent#2617
shikanime wants to merge 3 commits into
mainfrom
fix/gitlab-ci-variable-idempotent

Conversation

@shikanime

@shikanime shikanime commented Aug 28, 2026

Copy link
Copy Markdown
Member

Issues liées

#2616


Quel est le comportement actuel ?

Depuis le portage du provisioning des variables CI GitLab dans server-nestjs (issue #2538), la réconciliation d'un projet n'est pas idempotente. setGitlabRepoVariable et setGitlabGroupVariable créent une variable quand leur show scopé ne la trouve pas ; mais une réconciliation concurrente ou antérieure peut l'avoir créée entre-temps. GitLab impose l'unicité (key, environment_scope), donc la création échoue avec 400 "has already been taken" et propage l'erreur à toute la synchronisation SonarQube (ensureGitlabCiVariables → ensureProjectRepositories → ensureProjectGroup), que ce soit via l'événement project.upsert ou le cron.

Quel est le nouveau comportement ?

La collision de création est tolérée comme pour tous les autres getOrCreate* du fichier (createGroup, createSubGroup, createUser, getOrCreateRepo) : sur "has already been taken", la variable existante est rechargée puis réconciliée (no-op si identique, édition sinon) au lieu de faire échouer la synchronisation. Une seconde réconciliation devient un no-op.

Cette PR introduit-elle un breaking change ?

Non.

Autres informations

  • Test unitaire : collision de création pour une variable de dépôt et de groupe (no-op / édition / propagation des erreurs non-collision).
  • Test e2e : une seconde émission project.upsert ne lève pas (idempotence de la réconciliation).

@shikanime shikanime self-assigned this Aug 28, 2026
@shikanime shikanime added the bug Something isn't working label Aug 28, 2026
@shikanime shikanime added this to the 9.25.0 milestone Aug 28, 2026
@github-actions github-actions Bot added the built label Aug 28, 2026
@shikanime
shikanime force-pushed the fix/gitlab-ci-variable-idempotent branch 2 times, most recently from 135e1d3 to 78b70fc Compare August 28, 2026 14:20
@shikanime
shikanime changed the base branch from main to fix/uniformize-error-guards August 28, 2026 14:22
shikanime added a commit that referenced this pull request Aug 28, 2026
PR #2617's idempotent variable commit (78b70fc) deleted three unrelated
test blocks — auditor flag tests, pipeline trigger token tests, and
group Members tests — that exist on the base branch. This commit restores
them while keeping the legitimate idempotent variable tests added by the PR.

Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I2b7cffab1ad665f7f441c61f13a37f446a6a6964
@shikanime
shikanime marked this pull request as ready for review August 28, 2026 15:01
@shikanime
shikanime requested a review from a team as a code owner August 28, 2026 15:01
Base automatically changed from fix/uniformize-error-guards to main August 28, 2026 15:54
shikanime and others added 3 commits August 28, 2026 15:54
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: If066b86e9ee93fb1f33c9eb2a44eac076a6a6964
PR #2617's idempotent variable commit (78b70fc) deleted three unrelated
test blocks — auditor flag tests, pipeline trigger token tests, and
group Members tests — that exist on the base branch. This commit restores
them while keeping the legitimate idempotent variable tests added by the PR.

Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I2b7cffab1ad665f7f441c61f13a37f446a6a6964
…e guards

Addresses SonarQube S3604-style warnings on the ensure* variable writers and
restores the EOF newline stripped from the touched files.

Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I1ac1fb1bae0b821d9c0265bad089253e6a6a6964
@shikanime
shikanime force-pushed the fix/gitlab-ci-variable-idempotent branch from 0e29fbf to f332a9f Compare August 28, 2026 15:54
@cloud-pi-native-sonarqube

Copy link
Copy Markdown

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.

1 participant