Skip to content

fix(api): /healthz uptime_seconds + OPTIONS shim on shallow probes#189

Merged
mastermanas805 merged 1 commit into
masterfrom
fix/api-shallow-probes-uptime-and-options-2026-05-30
May 30, 2026
Merged

fix(api): /healthz uptime_seconds + OPTIONS shim on shallow probes#189
mastermanas805 merged 1 commit into
masterfrom
fix/api-shallow-probes-uptime-and-options-2026-05-30

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

Summary

  • BUG-P272: /healthz now emits uptime_seconds (int64) — canaries/agents can answer "how long has this pod been up?" without an extra metrics scrape.
  • BUG-API-024: OPTIONS /openapi.json no longer returns 405 for non-Origin probes.
  • BUG-API-025: same fix mirrored on /healthz, /livez, and /readyz.

Browser preflight (Origin set) still flows through fiberCORS; this PR only closes the no-Origin probe lane (curl, uptime-checkers, SDK probes).

Coverage block (rule 17)

Symptom:       OPTIONS /healthz, /livez, /readyz, /openapi.json => 405
Enumeration:   rg -n 'app\.(Get|Options).*"/(healthz|livez|readyz|openapi.json)"' internal/router/router.go
Sites found:   4 GET routes (livez:152, healthz:368, readyz:452, openapi.json:471)
Sites touched: 4 — one Options route added next to each Get
Coverage test: TestProbeOptionsHandlerCoversAllShallowProbes iterates
               the registry list of shallow probe paths and asserts
               204 + Allow header on every one — adding a new probe
               surface without the OPTIONS shim fails the test.
Live verified: pending CI auto-deploy (rule 14 SHA check after merge).

Test plan

  • go build ./... clean
  • go vet ./... clean
  • go test ./internal/router/... -short — 96% coverage; probeOptionsHandler 100%
  • TestHealthzShape pins uptime_seconds shape (int64, 40–45s range from fixed 42s offset)
  • TestProbeOptionsHandlerCoversAllShallowProbes iterates registry of {/livez,/healthz,/readyz,/openapi.json}
  • Live verify after merge: curl https://api.instanode.dev/healthz | jq .uptime_seconds returns integer; curl -X OPTIONS -i https://api.instanode.dev/openapi.json returns 204 + Allow header.

Inbox: BUG-P272, BUG-API-024, BUG-API-025

…UG-P272, BUG-API-024/025)

BUG-P272: /healthz now emits `uptime_seconds` (int64) so canaries /
agents can answer "how long has this pod been up?" without an extra
metrics scrape. processStartFunc() is a test-overridable seam; the
production process samples time.Now() at package load. Value is
rounded to seconds — sub-second jitter has no diagnostic value and
would defeat HTTP-cache dedup for any proxy in front.

BUG-API-024/025: bare `OPTIONS /<probe>` (no Origin header → fiberCORS
skips) used to return 405 for /livez, /healthz, /readyz, and
/openapi.json. Browser preflight still flows through the CORS
middleware; this commit adds a no-Origin probe-lane handler that
returns 204 + an Allow header listing GET, HEAD, OPTIONS.

Coverage block (rule 17):
Symptom:       OPTIONS /healthz, /livez, /readyz, /openapi.json => 405
Enumeration:   rg -n 'app\.(Get|Options).*"/(healthz|livez|readyz|openapi.json)"' internal/router/router.go
Sites found:   4 GET routes (livez:152, healthz:368, readyz:452, openapi.json:471)
Sites touched: 4 — one Options route added next to each Get
Coverage test: TestProbeOptionsHandlerCoversAllShallowProbes iterates
               the registry list of shallow probe paths and asserts
               204 + Allow header on every one — adding a new probe
               surface without the OPTIONS shim fails the test.
Live verified: pending CI auto-deploy (rule 14 SHA check after merge).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 force-pushed the fix/api-shallow-probes-uptime-and-options-2026-05-30 branch from 9829f34 to 6a998f5 Compare May 30, 2026 07:28
@mastermanas805 mastermanas805 merged commit 695c2b8 into master May 30, 2026
14 checks passed
@mastermanas805 mastermanas805 deleted the fix/api-shallow-probes-uptime-and-options-2026-05-30 branch May 30, 2026 07:43
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