Skip to content

No shared source of truth for the scan response type contract #30

Description

@mesrikanthreddy

Problem

The backend's `/api/v1/scan` response schema is hand-mirrored in three separate places with no shared definition and no CI check catching drift:

  • `cli/src/types.rs` (Rust)
  • `frontend/src/types/scan.ts` (TypeScript)
  • `vscode-extension/src/types.ts` (TypeScript)

`SKILLS.md` already flags this risk explicitly: "Changing the finding schema: if `app/api/v1/scan.py`'s response model changes, update `src/types.ts` in lockstep (mirrors the same contract used by `frontend/src/types/scan.ts` and `cli/src/types.rs`)." — currently enforced only by convention/documentation, not tooling.

Proposed fix

Options to evaluate:

  • Generate an OpenAPI schema from the FastAPI backend (`app.openapi()`) and codegen the TS/Rust types from it in CI, failing the build if committed types don't match
  • At minimum, add a CI check that fails if `scan.py`'s response model changes without corresponding changes to all three consumer type files (even a rough heuristic — e.g. flag the PR for manual review — beats silent drift)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions