You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(backend): add a public health endpoint - #819
GET /health returns 200 with {"status":"ok"} through the public router. The handler serves as a liveness check and does not query external services.
Verification
go test ./cmd/server -run '^TestHealthEndpoint$' -count=1 reproduced the original 404 and passed with the route in place.
go test ./... -count=1 passed with MongoDB 7 and MONGO_TEST_URI set to the disposable local instance.
go build ./... and go vet ./... passed. Both changed Go files were formatted with gofmt.
Prepared with AI assistance (Codex) for the route, regression test, and local checks.
Summary by CodeRabbit
New Features
Added a health-check endpoint that returns an “OK” status when the service is available. It can be checked with a GET /health request and does not require authentication.
The backend now exposes an unauthenticated GET /health endpoint. It returns HTTP 200 and {"status":"ok"}. A test checks the status code and JSON response.
Changes: Health endpoint
Layer / File(s)
Summary
Health route and response test backend/cmd/server/main.go, backend/cmd/server/main_test.go
The router registers GET /health and returns HTTP 200 with a JSON status of "ok". A test verifies the status code and response body.
This adds a simple public health endpoint that returns 200 with {"status":"ok"}. Browser clients on origins outside the configured CORS allowlist will get a 403 from it, as with every other route. That is minor and does not affect curl or CI use, so the change is low risk to merge.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
G'day, the title 'feat(backend): add a public health endpoint' fair dinkum matches the main change. The raw summary confirms main.go registers an unauthenticated GET /health route returning HTTP 200 w…
Linked Issues check
G'day. Issue #249 is the only active directly linked issue, so its requirements apply. Requirements: (1) a lightweight, unauthenticated GET /health route, (2) HTTP 200, (3) a small JSON body such as {…
Out of Scope Changes check
The PR touches two Go files only, per the summary: backend/cmd/server/main.go and backend/cmd/server/main_test.go. The main.go change is the single /health route. The test change covers that route. Bo…
Full details: Title check
Explanation
G'day, the title 'feat(backend): add a public health endpoint' fair dinkum matches the main change. The raw summary confirms main.go registers an unauthenticated GET /health route returning HTTP 200 with {"status":"ok"}, and main_test.go adds TestHealthEndpoint to check it. The linked objectives (issue #249) ask for this same lightweight public health endpoint, so the title is clear, specific and accurate.
Full details: Linked Issues check
Explanation
G'day. Issue #249 is the only active directly linked issue, so its requirements apply. Requirements: (1) a lightweight, unauthenticated GET /health route, (2) HTTP 200, (3) a small JSON body such as {"status":"ok"}, (4) no dependency on optional services such as Gemini or Redis, and (5) safe for local development and CI.
At the reviewed head, backend/cmd/server/main.go registers router.GET("/health", ...) in setupRouter. The route sits before the auth group, so it has no AuthMiddleware. The handler returns c.JSON(http.StatusOK, gin.H{"status": "ok"}) and makes no database, Redis, or Gemini calls. This meets requirements 1 to 4.
backend/cmd/server/main_test.go adds TestHealthEndpoint. It builds the router with setupRouter(nil, ""), sends GET /health, checks for 200, decodes the JSON, and checks status == "ok". This covers requirement 5 and shows the route works without a live backend.
Limit of evidence: the whole-PR diff tool was unavailable, so I did not compare against the merge base. I read the reviewed head files directly. The PR summary and description say the route is new (+5 lines in main.go, +27 in main_test.go), which matches the head content.
Full details: Out of Scope Changes check
Explanation
The PR touches two Go files only, per the summary: backend/cmd/server/main.go and backend/cmd/server/main_test.go. The main.go change is the single /health route. The test change covers that route. Both are directly tied to issue #249. The PR description reports gofmt, go vet, and go build checks. No unrelated routes, dependencies, or behaviour changes appear in the reviewed head content. Limit of evidence: the whole-PR diff tool was unavailable, so I could not confirm that no other hunks exist beyond the summary. The summary lists no other files.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
backend/cmd/server/main.go-109-109: 1
109-109: Minor · Functional Correctness · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Allow public health checks through CORS.
With the default allowlist, GET /health with Origin: http://localhost:3000 returns 403 before it reaches this handler. That prevents a local browser client on another origin from using the health check. The CORS middleware rejects disallowed origins. (raw.githubusercontent.com)
Apply a permissive CORS policy to /health without changing the policy for the other routes.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: d7749c29-aab9-4eb4-b32e-975d5c3754e5
Commits
Reviewing files that changed from the base of the PR and between 95b24b5 and b08f016.
Files selected for processing: 2
backend/cmd/server/main.go
backend/cmd/server/main_test.go
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
This branch has not been deployed
No deployments
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
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.
Closes #249.
GET /healthreturns200with{"status":"ok"}through the public router. The handler serves as a liveness check and does not query external services.Verification
go test ./cmd/server -run '^TestHealthEndpoint$' -count=1reproduced the original 404 and passed with the route in place.go test ./... -count=1passed with MongoDB 7 andMONGO_TEST_URIset to the disposable local instance.go build ./...andgo vet ./...passed. Both changed Go files were formatted withgofmt.Prepared with AI assistance (Codex) for the route, regression test, and local checks.
Summary by CodeRabbit
GET /healthrequest and does not require authentication.