Skip to content

server-nestjs: required config env (PROJECTS_ROOT_DIR) crashes container at startup — 3rd CI breakage from config migration #2377

Description

@shikanime

Summary

The server-nestjs container crashes at startup (~5.5s, declared unhealthy → a process crash, not a healthcheck timeout), which aborts the Playwright E2E job before any spec runs.

Root cause: apps/server-nestjs/src/config/base.config.ts (added by commit 29563dd "configuration to nestjs system") declares PROJECTS_ROOT_DIR as z.string().min(1) with no default. The CI Docker env template .env.docker-example does not set it, and nothing injects it. At boot, main.ts calls app.get(BASE_CONFIG)baseConfigFactory()zod throws "PROJECTS_ROOT_DIR: Required"app.listen never runs → process exits → container unhealthy → compose aborts.

Note: the consumed interface (apps/server-nestjs/src/modules/infrastructure/config/base.config.ts:18) already declares projectsRootDir?: string — optional. The zod schema was stricter than its own contract.

This is the 3rd CI breakage from the same configuration → module-definition migration:

  1. refactor: configuration to nestjs system #2290 build (TS2304) — open
  2. refactor(server-nestjs): configuration to module definition #2365 unit tests — open
  3. This: container startup crash (Playwright job 90233026446, run 30345985676)

Expected vs actual

  • Expected: container boots and passes healthcheck when PROJECTS_ROOT_DIR is unset (it is optional in the consumed interface; gitlab/argocd vault path generation only needs it when those features run).
  • Actual: process exits immediately with ZodError: PROJECTS_ROOT_DIR: Required.

Environment

Reproduction

  1. cp apps/server-nestjs/.env.docker-example apps/server-nestjs/.env.docker (leave PROJECTS_ROOT_DIR unset — it is absent from the template).
  2. Boot the server-nestjs service via pnpm docker:dev.
  3. Container exits unhealthy; logs show ZodError: PROJECTS_ROOT_DIR: Required.

Minimal unit repro:

import { baseConfigFactory } from "./config/base.config";
delete process.env.PROJECTS_ROOT_DIR;
baseConfigFactory(); // throws before fix, returns { projectsRootDir: "" } after fix

Fix (already applied on branch wt/t_7c23f271)

PROJECTS_ROOT_DIR was made optional in base.config.ts and gitlab.config.ts (the two registerAs-based zod schemas that require it), defaulting to "" in the transform. A regression spec src/config/base.config.spec.ts asserts the factory no longer throws when the var is unset (passes locally).

Follow-up / hardening

  • Audit every config registerAs schema for required env vars that are absent from the corresponding .env*docker/integ*-example templates before the next config-migration lands (close the pattern, not just this instance).
  • Add a CI guard: a smoke task that boots server-nestjs against the committed example env files and fails on non-zero exit, so a missing-env crash surfaces in the build stage rather than the E2E stage.
  • Consider a shared zod helper for "optional path env with safe default" to keep schemas consistent with their consumed interfaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CI/CDCI/CD stuffsbugSomething isn't workingtechnical debtRésoud de la dette technique

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions