CI: guard against generated frontend api.ts drift #680

Closed
opened 2026-05-27 14:22:01 +02:00 by marcel · 0 comments
Owner

Context

Recurring concern across PR #673 and PR #679 (Tobias/DevOps): when a backend model or endpoint changes, frontend/src/lib/generated/api.ts must be regenerated via npm run generate:api. In the import-migration phase work this file has repeatedly been hand-edited (no dev backend available in the isolated worktrees) to match the backend, and the only verification has been manual reading + reviewer cross-checks. There is no CI gate that fails when the committed api.ts drifts from what generate:api would produce.

Why it matters

A silent drift (a hand-edit that doesn't match the real OpenAPI output) ships type lies to the frontend — the exact failure mode that nearly bit #673.

Suggested approach

  • Add a CI step that regenerates the types and fails on diff. generate:api needs the OpenAPI spec — options:
    • Start the backend on the dev profile in CI (heavier), run npm run generate:api, then git diff --exit-code frontend/src/lib/generated/api.ts; or
    • Have the backend build emit openapi.json as an artifact, and run openapi-typescript against that file in the frontend job (no running backend needed), then diff.
  • Prefer the artifact approach if feasible — no live backend in the frontend job.

Out of scope / notes

  • Not blocking any phase PR — the hand-edits have been reviewer-verified each time. This is hardening so future drift fails loudly.
  • Surfaced again in #679's review.
## Context Recurring concern across PR #673 and PR #679 (Tobias/DevOps): when a backend model or endpoint changes, `frontend/src/lib/generated/api.ts` must be regenerated via `npm run generate:api`. In the import-migration phase work this file has repeatedly been **hand-edited** (no dev backend available in the isolated worktrees) to match the backend, and the only verification has been manual reading + reviewer cross-checks. There is no CI gate that fails when the committed `api.ts` drifts from what `generate:api` would produce. ## Why it matters A silent drift (a hand-edit that doesn't match the real OpenAPI output) ships type lies to the frontend — the exact failure mode that nearly bit #673. ## Suggested approach - Add a CI step that regenerates the types and fails on diff. `generate:api` needs the OpenAPI spec — options: - Start the backend on the `dev` profile in CI (heavier), run `npm run generate:api`, then `git diff --exit-code frontend/src/lib/generated/api.ts`; or - Have the backend build emit `openapi.json` as an artifact, and run `openapi-typescript` against that file in the frontend job (no running backend needed), then diff. - Prefer the artifact approach if feasible — no live backend in the frontend job. ## Out of scope / notes - Not blocking any phase PR — the hand-edits have been reviewer-verified each time. This is hardening so future drift fails loudly. - Surfaced again in #679's review.
marcel added the P2-mediumdevops labels 2026-05-27 14:22:36 +02:00
Sign in to join this conversation.
No Label P2-medium devops
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#680