Skip to content

feat(backend): add a public health endpoint - #819

Open
MuhammadFaizan-prog wants to merge 1 commit into
AOSSIE-Org:mainfrom
MuhammadFaizan-prog:codex/debateai-249-health
Open

MuhammadFaizan-prog wants to merge 1 commit into
AOSSIE-Org:mainfrom
MuhammadFaizan-prog:codex/debateai-249-health

Conversation

@MuhammadFaizan-prog

@MuhammadFaizan-prog MuhammadFaizan-prog commented Nov 27, 2026 •

Copy link
Copy Markdown

Closes #249.

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.

Signed-off-by: Muhammad Faizan <130775084+MuhammadFaizan-prog@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature · Severity of issue fixed: Low

Suggested reviewers: zaibamachhaliya, shreyas-gowda26

Merge Risk: Low · up to b08f0

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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed 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 Passed 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.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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
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.

Backend missing a /health endpoint for basic service status checks

1 participant