Skip to content

fix: endpoint failures use the standard error shape and count in metrics - #197

Merged
blaipr merged 1 commit into
mainfrom
fix/endpoint-error-bodies
Aug 26, 2026
Merged

fix: endpoint failures use the standard error shape and count in metrics#197
blaipr merged 1 commit into
mainfrom
fix/endpoint-error-bodies

Conversation

@blaipr

@blaipr blaipr commented Aug 26, 2026

Copy link
Copy Markdown
Member

What

  • The output endpoint's failure paths (500 script/builtin failure, 504 timeout, the neither-output-nor-script guard) rendered hand-built json! bodies; they now flow through ApiError — one source for the shape, finishing the migration error.rs describes.
  • Metrics bug: a timed-out run returned before the counters, so unified_api_endpoint_total never counted it — despite docs/endpoints.md promising that timed-out runs count as result="error" ("so alerting on the error rate catches hung transformers too"). Timeouts and builtin-render panics now flow through the counters and the duration histogram before answering.
  • The 503 keeps its missing_sources list (now sorted, deterministic) under a declared EndpointUnavailableBody schema instead of an undeclared ad-hoc body.
  • #[utoipa::path] on both endpoint handlers now declares 500/503/504 with their bodies, and GET /metrics joins the OpenAPI spec — it was the only routed handler missing from it, and the spec never mentioned that server.metrics_require_auth moves it behind the key.

Tests

New tests/adapters/out/output/slow.py sample transformer plus an integration test: a script endpoint with timeout_seconds: 1 answers 504 whose body is the standard {"error": ...} shape naming the limit it hit.

Note: a_cron_scheduled_source_syncs_into_the_cache and a_reload_replaces_the_running_task_generation flaked once under full-suite parallel load and pass in isolation and on re-run — pre-existing timing sensitivity, unrelated to this diff.

The output endpoint's 500 and 504 bodies were hand-built JSON; they now
render through ApiError like every other failure, the 503 keeps its
missing_sources list under a declared EndpointUnavailableBody schema, and
all failure statuses appear in the OpenAPI spec. A timed-out run also
returned before the counters, so unified_api_endpoint_total never saw it
despite the docs saying it counts as result=error — it flows through them
now. GET /metrics joins the OpenAPI spec as well.
@blaipr
blaipr force-pushed the fix/endpoint-error-bodies branch from 6c504c1 to fa58a36 Compare August 26, 2026 12:03
@blaipr
blaipr merged commit 96d8dac into main Aug 26, 2026
6 checks passed
@blaipr
blaipr deleted the fix/endpoint-error-bodies branch August 26, 2026 12:08
@blaipr blaipr mentioned this pull request Aug 26, 2026
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