fix: update healthcheck to use server address and port individually#698
Conversation
📝 WalkthroughWalkthroughReplace hardcoded default app URL with environment-driven configuration. The healthcheck now reads TINYAUTH_SERVER_ADDRESS and TINYAUTH_SERVER_PORT environment variables, applying sensible defaults (127.0.0.1 and 3000) when unset, with optional CLI argument override. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmd/tinyauth/healthcheck.go`:
- Around line 31-41: The healthcheck builds appUrl using TINYAUTH_SERVER_ADDRESS
(srvAddr) which may be set to the non-routable bind address "0.0.0.0"; normalize
srvAddr before formatting appUrl by treating "0.0.0.0" (and optionally empty) as
"127.0.0.1" so the healthcheck connects to a routable loopback; update the logic
around srvAddr/srvPort used to build appUrl in healthcheck.go (the variables
srvAddr, srvPort, and appUrl) to perform this normalization.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7ef28af6-2a8d-4557-837b-594e3c101eb1
📒 Files selected for processing (1)
cmd/tinyauth/healthcheck.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #698 +/- ##
==========================================
- Coverage 15.23% 15.22% -0.01%
==========================================
Files 50 50
Lines 3696 3698 +2
==========================================
Hits 563 563
- Misses 3076 3078 +2
Partials 57 57 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
healthcheckCmddoes not return healthy when using only the server port variableProblem
TINYAUTH_SERVER_PORTenv variable is only used for creating the appUrl variable to check healthness when in combination withTINYAUTH_SERVER_ADDRESS, to have the healthcheck properly working we need to send the two variablesSolution
Allow to use any of the variables independent of the other, using the default values for both of them as previously was before
Summary by CodeRabbit