Add Twilio HealthCheck to Boilerplate (#12297)#12300
Conversation
WalkthroughA new Twilio health-check service was added to the Boilerplate template that verifies Twilio SMS configuration and account status. The service returns a healthy/skipped result if SMS is not configured, checks Twilio account details if configured, and reports account status accordingly. The health check was registered in the service collection. Changes
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Infrastructure/Services/TwilioHealthCheck.cs`:
- Around line 18-19: The health check in TwilioHealthCheck currently treats any
non-true Sms?.Configured as “skipped” healthy, which hides partial configuration
errors; update the logic in the TwilioHealthCheck (the method that reads
settings.Sms?.Configured) to distinguish three cases: (1) fully unconfigured —
keep returning Healthy with the skip message, (2) fully configured — perform the
normal Twilio check and return Healthy/Unhealthy based on the probe, and (3)
partially configured — return HealthCheckResult.Unhealthy with a clear message
listing which required Twilio fields (e.g., AccountSid, AuthToken,
From/PhoneNumber) are missing or empty so partial setups are surfaced. Ensure
you reference and validate the actual properties on settings.Sms before deciding
to skip versus fail.
- Around line 14-22: The health check in TwilioHealthCheck.CheckHealthAsync
calls AccountResource.FetchAsync without honoring the passed cancellationToken,
so wrap the fetch in a cancellable/timeout pattern (e.g., start the fetch task
and await Task.WhenAny(fetchTask, Task.Delay(timeout, cancellationToken))) and
if the delay/cancellation completes first, abort waiting and return an
Unhealthy/Degraded HealthCheckResult indicating a timeout/cancellation; ensure
you pass/observe the incoming cancellationToken (or a linked
CancellationTokenSource) when creating the timeout Task so the method returns
promptly on cancellation and does not hang indefinitely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d998f683-cb80-4fd5-bb8a-22089aa40cf7
📒 Files selected for processing (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Infrastructure/Services/TwilioHealthCheck.cssrc/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs
closes #12297
Summary by CodeRabbit