feat(health): expose running app version metadata#4757
Conversation
|
@byigitt is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
PR SummaryLow Risk Overview The route is wired through the shared API contract layer (passthrough query params for probes like Docker/CI: Docs: README documents Reviewed by Cursor Bugbot for commit c1f7e4d. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR exposes
Confidence Score: 3/5The core metadata plumbing (env vars, Dockerfile, CI) is solid, but the health endpoint now rejects requests with any query parameter, which could cause real health probes to report the service as unhealthy. The health route wraps its response in parseRequest with a strict noInputSchema. Any monitoring tool, load balancer probe, or cache-busting request that appends even a single query parameter will receive a 400 instead of the expected 200, silently marking the instance unhealthy. The previous handler returned 200 unconditionally. This regression is confined to one file and has a straightforward fix, but it affects the reliability of deployment health checks in production. apps/sim/app/api/health/route.ts — the strict query validation wrapping a health endpoint that should always respond 200. Important Files Changed
Sequence DiagramsequenceDiagram
participant Probe as Health Probe / curl
participant Route as GET /api/health
participant PR as parseRequest (noInputSchema strict)
participant Env as process.env
Probe->>Route: GET /api/health
Route->>PR: "parseRequest(healthContract, request, {})"
alt No query params
PR-->>Route: "{ success: true }"
Route->>Env: APP_VERSION, GIT_SHA etc.
Env-->>Route: version, commit
Route-->>Probe: "200 { status, timestamp, version, commit }"
else "Any unexpected query param (e.g. ?_=ts)"
PR-->>Route: "{ success: false, response: 400 }"
Route-->>Probe: 400 Validation error
end
Reviews (1): Last reviewed commit: "feat(health): expose running app version..." | Re-trigger Greptile |
| const parsed = await parseRequest(healthContract, request, {}) | ||
| if (!parsed.success) return parsed.response |
There was a problem hiding this comment.
Strict query validation can cause health probes to return 400
healthContract uses noInputSchema which is z.object({}).strict(). Any request carrying unexpected query parameters — e.g. ?_=1234567890 (cache-busting), ?format=json (monitoring tools), or any debugging param — will fail Zod strict validation and return a 400 before the health payload is produced. The previous handler accepted no request argument at all and would return 200 unconditionally. Kubernetes liveness/readiness probes, uptime checkers, and other health-poll tools sometimes append arbitrary params; this change silently turns those into "unhealthy" signals.
Note also that parsed.data is never read inside the handler — the contract's query validation is pure overhead here. Consider removing the parseRequest call entirely, or using a passthrough/permissive query schema, to preserve the unconditional 200 behaviour that health endpoints are expected to provide.
| version: '0.1.0', | ||
| commit: null, |
There was a problem hiding this comment.
The fallback version is hardcoded as
'0.1.0' in the test, but it is derived at runtime from appPackage.version in the route. If the package.json version is ever bumped, this assertion will fail without an obvious cause. Importing the package version directly makes the assertion resilient to version changes.
| version: '0.1.0', | |
| commit: null, | |
| version: expect.any(String), | |
| commit: null, |
This adds version and commit metadata to
/api/healthso self-hosted instances can report what is running.Testing:
Closes #2014