Skip to content

fix(backend): include surface flag in OpenAPI stale-contract hint#10294

Open
kodjima33 wants to merge 1 commit into
mainfrom
issues-improver/10217-openapi-surface-flag-hint
Open

fix(backend): include surface flag in OpenAPI stale-contract hint#10294
kodjima33 wants to merge 1 commit into
mainfrom
issues-improver/10217-openapi-surface-flag-hint

Conversation

@kodjima33

@kodjima33 kodjima33 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

What

The --check failure hint in backend/scripts/export_openapi.py now includes the surface-selection flag, so following it verbatim regenerates the correct surface.

Why

From #10217:

Following that command verbatim silently exports the public surface (surface defaults to public) into the app-client file — 53k lines deleted, wrong contract — because surface selection is a separate flag, not inferred from the output path. The correct command is backend/scripts/export_openapi.py --app-client --write.

Evidence: hit while preparing #10215 today; the wrong invocation produced a 17-path public spec in place of the 309-path app-client spec and --check (also without the flag) then validated the wrong surface as 'up to date'.

check_spec had no knowledge of which surface was being checked, so its is stale / does not exist hints always emitted the bare --write <path> command, which defaults to the public surface.

Change

  • check_spec(path, generated, surface='public') now prefixes the correct selector via a new surface_flag() helper: --app-client for app-client, --surface integration-public for integration-public, empty for public (default invocation unchanged).
  • main() passes args.surface into check_spec.
  • Regression test test_stale_hint_includes_surface_flag_for_non_public_surfaces asserts each surface's hint carries its selector and that public stays flag-free.

Verified

  • Exercised the real check_spec code path for all three surfaces plus the does-not-exist branch (via the pinned openapi runner venv): every hint carries the right flag; the public hint is byte-for-byte the previous default.
    • app-client → ... run backend/scripts/export_openapi.py --app-client --write <path>
    • integration-public → ... --surface integration-public --write <path>
    • public → ... export_openapi.py --write <path> (unchanged)
  • tests/unit/test_openapi_contract.py — 15 passed (including the new regression test).
  • black --line-length 120 --skip-string-normalization clean on both files.

Auto-generated from issue feedback by the mini issues-improver. Review before merge.

Review in cubic

The stale/missing-file hint from export_openapi.py's --check told users to
run `export_openapi.py --write <path>`, omitting the surface-selection flag.
Surface is a separate flag (defaults to `public`), not inferred from the
output path, so following the hint verbatim for a non-public surface silently
exports the public surface into the wrong file (e.g. 17-path public spec
overwriting the 309-path app-client spec) and --check then validates the wrong
surface as up to date.

check_spec now takes the surface and prefixes the correct flag
(`--app-client ` / `--surface integration-public `; empty for public) in both
the stale and does-not-exist hints. Regression test asserts each surface's
hint carries its selector.

Verified: exercised check_spec directly for all three surfaces plus the
does-not-exist branch (correct flag in every hint, public unchanged); full
tests/unit/test_openapi_contract.py green (15 passed) via the pinned openapi
runner venv.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant