Skip to content

refactor: conditional module activation - #2381

Merged
shikanime merged 1 commit into
mainfrom
shikanime/push-yztnkuuslsmy
Jul 30, 2026
Merged

refactor: conditional module activation#2381
shikanime merged 1 commit into
mainfrom
shikanime/push-yztnkuuslsmy

Conversation

@shikanime

@shikanime shikanime commented Jul 28, 2026

Copy link
Copy Markdown
Member

Signed-off-by: William Phetsinorath william.phetsinorath-open@interieur.gouv.fr
Change-Id: I6f501bd1633ceb14edaa9bf2a324ea026a6a6964

Issues liées

Issues numéro: #2380


Quel est le comportement actuel ?

Quel est le nouveau comportement ?

Cette PR introduit-elle un breaking change ?

Autres informations

@shikanime shikanime self-assigned this Jul 28, 2026
@shikanime shikanime added the tech Technical issue label Jul 28, 2026
@shikanime shikanime added this to the 9.23.0 milestone Jul 28, 2026
Comment thread apps/server-nestjs/src/main.module.ts Fixed
@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch 2 times, most recently from 546e3d4 to a5e314e Compare July 28, 2026 13:55
@github-actions github-actions Bot added the built label Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch 4 times, most recently from 5e2c7bd to 477e838 Compare July 28, 2026 15:11
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

3 similar comments
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime

Copy link
Copy Markdown
Member Author

Review: PR #2381 — conditional module activation

Production refactor is sound: builds, full suite green (407 passed, e2e skipped), all new specs pass, DI resolution is correct. One blocker on test design, two nits, one info item. (Posting as a comment since GitHub won't let me request-changes on my own PR.)

WARNING — plugin.module.spec.ts tests the harness, not the module

apps/server-nestjs/src/modules/plugin/plugin.module.spec.ts wraps PluginModule in ConditionalModule.registerWhen(PluginModule, 'USE_X') and asserts PluginService is absent when USE_X=false. That only proves @nestjs/config's registerWhen gates the whole module — it never exercises plugin.module.ts's internal conditional imports (registerWhen(ArgoCDModule,'USE_ARGOCD'), etc.). In production main.module.ts imports PluginModule directly (unconditional), so this scenario never occurs.

Worse, the USE_KEYCLOAK (L34) and USE_VAULT (L58) cases assert gates that do not exist in plugin.module.tsKeycloakModule and VaultModule are imported unconditionally there. Those two tests pass only because of the harness wrap and actively mislead a future reader into thinking PluginModule is gated by those flags.

Fix: load PluginModule directly (drop the harness registerWhen wrapper) and assert the downstream services' presence/absence, e.g. module.get(ArgoCDService) present when USE_ARGOCD=true / throws when false — mirroring the correct pattern already in argocd.module.spec.ts. Remove the USE_KEYCLOAK/USE_VAULT cases (or add the real gates to plugin.module.ts if gating was intended).

NIT — CRLF line endings

apps/server-nestjs/src/modules/service-chain/service-chain-health.service.ts is committed with CRLF (confirmed: blob i/crlf, 30 CR bytes) while the rest of the repo is LF. No prettier/eslint gate enforces it here, but normalize to LF for consistency.

NIT — redundant ConfigModule.forRoot()

healthz.module.ts:18 calls ConfigModule.forRoot(). ConfigModule is global and ConfigurationModule already calls forRoot({...}) with options. The explicit import/forRoot in healthz is redundant — drop it and rely on the global instance.

INFO — health probe key rename (possible minor breaking change)

healthz.controller previously reported the OpenCds probe under key 'opencds'; HealthzService.check() now passes 'serviceChain'. Confirm no external monitor/alert keys on 'opencds' in the health payload before merging.

Verified OK

  • @nestjs/config@4.0.3 provides ConditionalModule — version fine.
  • All XxxHealthService providers are exported by their modules; @Optional() DI in HealthzService is correct (probe omitted when its module is not loaded).
  • No dangling refs to deleted OpenCdsModule/OpenCdsHealthService.
  • No security issues; controller auth posture unchanged (was already unguarded).

@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch from 477e838 to cd5ac06 Compare July 28, 2026 16:07
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch 2 times, most recently from a14484a to 6100723 Compare July 28, 2026 16:49
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch from 6100723 to bf84e68 Compare July 28, 2026 16:56
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch from bf84e68 to 6bb5e00 Compare July 28, 2026 17:21
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch from 6bb5e00 to 80f347b Compare July 28, 2026 17:47
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

Comment thread apps/server-nestjs/src/modules/healthz/healthz.service.spec.ts
@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch from 471ddc1 to d5319ac Compare July 29, 2026 15:29
@StephaneTrebel
StephaneTrebel self-requested a review July 29, 2026 15:30
StephaneTrebel
StephaneTrebel previously approved these changes Jul 29, 2026
@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch 6 times, most recently from 5d44868 to c568328 Compare July 29, 2026 16:35
KepoParis
KepoParis previously approved these changes Jul 29, 2026
@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch 2 times, most recently from c474296 to 13d3d55 Compare July 29, 2026 16:44
@shikanime
shikanime force-pushed the shikanime/push-yztnkuuslsmy branch 4 times, most recently from ba391c5 to 5e9fe49 Compare July 29, 2026 17:00
KepoParis
KepoParis previously approved these changes Jul 29, 2026
Comment thread apps/server-nestjs/.env.docker-example Outdated
Comment thread apps/server-nestjs/.env-example Outdated
Comment thread apps/server-nestjs/src/main.module.ts Outdated
Comment thread apps/server-nestjs/src/modules/healthz/healthz.module.ts
Comment thread apps/server-nestjs/src/main.module.ts Fixed
Comment thread apps/server-nestjs/src/modules/plugin/plugin.module.spec.ts Fixed
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I6f501bd1633ceb14edaa9bf2a324ea026a6a6964
@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

built tech Technical issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants