Conversation
|
Thanks for opening this, but we'd appreciate a little more information. Could you update it with more details? |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR refactors ChangesTtsAudioService Lazy RestClient Factory
Defensive Null Handling and Diagnostics
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Core/Resgrid.Services/LimitsService.cs (1)
127-140:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winCritical: Add null-check for plan before accessing
plan.PlanIdon line 131.Per coding guidelines,
SubscriptionsService.GetCurrentPlanForDepartmentAsync()can returnnullwhen the Billing API response is unavailable. Accessingplan.PlanIdwithout a null-check will cause aNullReferenceException.The added diagnostic log (line 138) is valuable, but it cannot execute if the method crashes on line 131. The null-check must come before the
plan.PlanIdcomparison.🛡️ Proposed fix: Add null-check before accessing plan.PlanId
public async Task<bool> CanDepartmentProvisionNumberAsync(int departmentId) { var plan = await _subscriptionsService.GetCurrentPlanForDepartmentAsync(departmentId); + + if (plan == null) + { + Resgrid.Framework.Logging.LogInfo($"[Twilio SMS] CanDepartmentProvisionNumber=false for DepartmentId={departmentId} — plan is null (Billing API unavailable), so no SMS reply will be generated."); + return false; + } if (plan.PlanId == 4 || plan.PlanId == 5 || plan.PlanId == 10 || plan.PlanId == 14 || plan.PlanId == 15 || plan.PlanId == 16 || plan.PlanId == 17 || plan.PlanId == 18 || plan.PlanId == 19 || plan.PlanId == 20 || plan.PlanId == 21 || plan.PlanId == 26 || plan.PlanId == 27 || plan.PlanId == 28 || plan.PlanId == 29 || plan.PlanId == 30 || plan.PlanId == 31 || plan.PlanId == 32 || plan.PlanId == 33 || plan.PlanId == 36 || plan.PlanId == 37) return true; - // Diagnostic: this gate silently blocks the inbound-SMS text-command reply path. Log the - // resolved plan so it is clear *why* a department gets no reply (plan not in the allow-list). - Resgrid.Framework.Logging.LogInfo($"[Twilio SMS] CanDepartmentProvisionNumber=false for DepartmentId={departmentId} PlanId={plan.PlanId} — plan is not in the number/text-feature allow-list, so no SMS reply will be generated."); + // Diagnostic: this gate silently blocks the inbound-SMS text-command reply path. Log the + // resolved plan so it is clear *why* a department gets no reply (plan not in the allow-list). + Resgrid.Framework.Logging.LogInfo($"[Twilio SMS] CanDepartmentProvisionNumber=false for DepartmentId={departmentId} PlanId={plan.PlanId} — plan is not in the number/text-feature allow-list, so no SMS reply will be generated."); return false; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Core/Resgrid.Services/LimitsService.cs` around lines 127 - 140, The CanDepartmentProvisionNumberAsync method accesses plan.PlanId without first checking if the plan object returned from GetCurrentPlanForDepartmentAsync is null, which will cause a NullReferenceException since the subscription service can return null when the Billing API is unavailable. Add a null-check immediately after the await call to GetCurrentPlanForDepartmentAsync and return false if the plan is null, before attempting to access any properties on the plan object.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@Core/Resgrid.Services/LimitsService.cs`:
- Around line 127-140: The CanDepartmentProvisionNumberAsync method accesses
plan.PlanId without first checking if the plan object returned from
GetCurrentPlanForDepartmentAsync is null, which will cause a
NullReferenceException since the subscription service can return null when the
Billing API is unavailable. Add a null-check immediately after the await call to
GetCurrentPlanForDepartmentAsync and return false if the plan is null, before
attempting to access any properties on the plan object.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f32bc24c-eeab-4908-ad3b-89f22bf610b9
⛔ Files ignored due to path filters (1)
Tests/Resgrid.Tests/Web/Services/TtsAudioServiceTests.csis excluded by!**/Tests/**
📒 Files selected for processing (5)
Core/Resgrid.Services/LimitsService.csCore/Resgrid.Services/ServicesModule.csCore/Resgrid.Services/TtsAudioService.csWeb/Resgrid.Web.Services/Controllers/TwilioController.csWeb/Resgrid.Web/Areas/User/Controllers/SubscriptionController.cs
|
Approve |
Summary by CodeRabbit
Bug Fixes
Improvements