Repository navigation
feat(api): declare the 400 response on compute routes (#209) - #211
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 only200/422were declared in the OpenAPI spec. This declares the 400 so the contract is explicit and the generated client types the error body.What
ApiError({detail: string}) + a sharedBAD_REQUEST_RESPONSEinfiberpath_api/schemas.py.responses=BAD_REQUEST_RESPONSEon/plan,/simulate,/validate; spread it alongside theimage/png200 on/plot.openapi.json+ the TS client (now types the 400).tests/api/test_openapi_contract.pypins the 400 +ApiErrorin 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 nowarnings.warn/LOGGER.warningin 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/mypyclean ·pytest tests/api16 passed · OpenAPI drift gate clean on regen.