Skip to content

Harden API route error handling (plan/simulate 500s, stream payload cap) #104

Closed

Description

@CameronBrooks11

What

Catch core engine exceptions in the API plan/simulate routes and return appropriate 4xx responses, mirroring the CLI. Optionally add a payload-size cap to /stream.

Why

plan_wind() and simulate_program() can raise LayerValidationError / SimulationError for bad input. The CLI handles these and exits cleanly; the API routes do not, so they surface as opaque HTTP 500s instead of actionable 4xx errors. This is an interface-parity gap.

The /stream endpoint also accepts an unbounded G-code string, which is a minor memory-exhaustion hardening item if the API is ever exposed beyond localhost.

Where

  • fiberpath_api/routes/plan.py:29 — plan_wind(...) uncaught
  • fiberpath_api/routes/simulate.py:20 — simulate_program(...) uncaught (note: SimulationError is not currently imported)
  • fiberpath_api/routes/stream.py / schemas.py StreamRequest.gcode — no max_length

Acceptance criteria

  • Planning validation errors return HTTP 400 with the error message, not 500
  • Simulation errors return an appropriate 4xx, not 500
  • Optional: StreamRequest.gcode has a sane max_length bound
  • Tests cover the error paths for both routes

Activity

  1. added
    python
    on Jun 24, 2026
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

    python

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions