Skip to content

fix(runner): drop JSON content-type on bodyless light-run requests#20

Merged
enixCode merged 1 commit into
mainfrom
fix/teardown-empty-json-body
Jun 2, 2026
Merged

fix(runner): drop JSON content-type on bodyless light-run requests#20
enixCode merged 1 commit into
mainfrom
fix/teardown-empty-json-body

Conversation

@enixCode
Copy link
Copy Markdown
Owner

@enixCode enixCode commented Jun 2, 2026

Problem (found in manual e2e of networks + services)

Service and network teardown silently failed. After a workflow with services + networkDefs finished, the sidecar service container kept running and its run-scoped network leaked.

Root cause

stopRun (POST /runs/:id/stop), the run cancel (POST /runs/:id/cancel), and deleteNetwork (DELETE /networks/:name) all sent content-type: application/json with no body. Fastify rejects an empty body under that content-type with 400 FST_ERR_CTP_EMPTY_JSON_BODY, before the route handler runs. stopServices and the executor teardown swallow per-item errors (best-effort), so:

  1. stopRun -> 400 -> swallowed -> service container never stopped
  2. deleteNetwork -> 400 (and would 409 anyway, network still attached) -> network leaked

A curl -X POST .../stop with no content-type header returns 204 and works, which is why the endpoint looked fine in isolation.

Fix

  • add authHeaders() (bearer token only, no content-type) for bodyless requests
  • POST /runs/:id/stop, POST /runs/:id/cancel, DELETE /networks/:name use it

Verified end-to-end

light run net (networkDef + echo service + probe node): before, the echo container stayed Up and lp-<run>-svc-net leaked after [ok]. After: probe still gets 200, then the service is stopped (run -> cancelled) and the network deleted, no leaks, no stuck running runs.

build with cc

Service and network teardown silently failed end-to-end. stopRun, the run
cancel, and deleteNetwork sent `content-type: application/json` with no body,
and Fastify rejects an empty body under that content-type with 400
(FST_ERR_CTP_EMPTY_JSON_BODY). stopServices and the teardown swallowed the
error, so the sidecar service container kept running and its run-scoped network
leaked (deletion then 409'd on the still-attached container).

- add authHeaders() (bearer only, no content-type) for bodyless requests
- POST /runs/:id/stop, POST /runs/:id/cancel and DELETE /networks/:name use it

build with cc
@enixCode enixCode merged commit 80219b3 into main Jun 2, 2026
5 checks passed
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