Skip to content

feat(api): declare the 400 response on compute routes (#209) - #211

Merged
CameronBrooks11 merged 1 commit into
mainfrom
feat/plan-warnings-and-400-209
Jun 26, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
feat/plan-warnings-and-400-209

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Closes #209.

The compute routes map invalid-but-well-formed input to HTTP 400 (PlanningError/SimulationError/PlotError → exception handlers, plus the explicit empty-program 400s), but only 200/422 were declared in the OpenAPI spec. This declares the 400 so the contract is explicit and the generated client types the error body.

What

  • Add ApiError ({detail: string}) + a shared BAD_REQUEST_RESPONSE in fiberpath_api/schemas.py.
  • Declare responses=BAD_REQUEST_RESPONSE on /plan, /simulate, /validate; spread it alongside the image/png 200 on /plot.
  • Regenerate openapi.json + the TS client (now types the 400).
  • tests/api/test_openapi_contract.py pins the 400 + ApiError in the spec.

Descope (the "structured planner warnings" half of #209)

Dropped as unnecessary. Investigation: the planner emits no non-fatal warnings — every advisory check raises LayerValidationError (→ 400), and there's no warnings.warn/LOGGER.warning in core. The GUI's old preview "warnings" were scraped CLI stderr (error text / logging noise), so #193's empty warnings list is not a regression. Genuine advisory warnings would be a new feature (open a fresh issue if wanted).

Review

Independent review: SHIP (no blocking). Verified the 400 declaration on all four routes, the regenerated client types the error, the drift gate is clean, mypy/tests pass, and the descope claim is true (no planner warnings).

Verification

  • ruff/mypy clean · pytest tests/api 16 passed · OpenAPI drift gate clean on regen.

The /plan, /simulate, /validate, and /plot routes map invalid-but-
well-formed input to HTTP 400 (PlanningError/SimulationError/PlotError ->
exception handlers, plus the explicit empty-program 400s), but only
200/422 were declared in the OpenAPI spec. Add an `ApiError` model
({"detail": str}) and a shared `BAD_REQUEST_RESPONSE` so each route
declares 400 — making the contract explicit and letting the generated
client type the error body. Regenerate openapi.json + the TS client.

Scopes the 400-declaration half of #209. The "structured planner
warnings" half is dropped: investigation shows the planner has no
non-fatal warnings (every check raises LayerValidationError -> 400), so
the GUI's old stderr-scraped "warnings" carried nothing — #193's empty
warnings list is not a regression. (Advisory warnings would be a new
feature, tracked separately if wanted.)

Part of #209.
@CameronBrooks11
CameronBrooks11 merged commit fe1e2f1 into main Jun 26, 2026
21 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/plan-warnings-and-400-209 branch June 26, 2026 06:08
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.

API contract polish: declare 400 responses + structured planner warnings

1 participant