fix: release Biorender semaphore permit on invalid email#209
Conversation
GetBiorenderStudentInfo called throttler.WaitAsync before checking IsValidEmail, but Release only ran inside the scheduled task. Each invalid email consumed a permit permanently, so 20 invalid entries in a row would deadlock the loop on WaitAsync. Move trim/validation ahead of WaitAsync and `continue` on invalid so permits are only acquired when work is actually scheduled. Caught in CodeRabbit review of #192. Split from #192 because this is a control-flow correction, not a dispose-hygiene change.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #209 +/- ##
=======================================
Coverage 43.02% 43.02%
=======================================
Files 881 881
Lines 51437 51437
Branches 4812 4812
=======================================
Hits 22131 22131
Misses 28780 28780
Partials 526 526
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Bundle ReportBundle size has no change ✅ |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesEmail Validation and Semaphore Optimization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Summary
BiorenderStudentLookup.GetBiorenderStudentInfoacquires a semaphore permit viathrottler.WaitAsync()before checkingIsValidEmail, butRelease()only runs inside the scheduledTask.Run. Each invalid email permanently consumes a permit, so 20 invalid entries in a row deadlock the loop atWaitAsync()waiting for permits that will never be returned.Fix
Reorder: trim and validate first,
continueon invalid, thenWaitAsynconly when work is actually being scheduled.Context
Split from #192 (CodeQL dispose hygiene). CodeRabbit surfaced this during the #192 review, but it is a control-flow correction rather than a dispose annotation, so it lives here for cleaner
git log/bisect.Independent of #192 — either can merge first. Touches adjacent lines on
var throttler = new SemaphoreSlim(...)so a trivial merge resolution may be needed for whichever lands second (keep theusingfrom #192, keep the reorder from here).Test plan
npm run test:backend— 1946 tests passingnpm run lint web/Areas/Computing/Services/BiorenderStudentLookup.cs— cleannpm run verify:build— cleanGetBiorenderStudentInfowith >20 invalid emails, confirm it returns (currently hangs)