fix(api): /healthz uptime_seconds + OPTIONS shim on shallow probes#189
Merged
mastermanas805 merged 1 commit intoMay 30, 2026
Merged
Conversation
…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>
9829f34 to
6a998f5
Compare
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.
Summary
/healthznow emitsuptime_seconds(int64) — canaries/agents can answer "how long has this pod been up?" without an extra metrics scrape.OPTIONS /openapi.jsonno longer returns 405 for non-Origin probes./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)
Test plan
go build ./...cleango vet ./...cleango test ./internal/router/... -short— 96% coverage; probeOptionsHandler 100%uptime_secondsshape (int64, 40–45s range from fixed 42s offset)curl https://api.instanode.dev/healthz | jq .uptime_secondsreturns integer;curl -X OPTIONS -i https://api.instanode.dev/openapi.jsonreturns 204 + Allow header.Inbox: BUG-P272, BUG-API-024, BUG-API-025