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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR normalizes audit query datetimes and binds them as DateTime2, switches RabbitMQ channels/connections to async disposal with proper reset handling, and corrects getting/setting normalized usernames in the identity store. ChangesInfrastructure safety and resource cleanup fixes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant AuditService
participant AuditLogsRepository
participant SQLDatabase
Caller->>AuditService: GetAuditLogsForDepartmentPagedAsync(startDate,endDate)
AuditService->>AuditService: Compute safeStart (clamp to SqlDateTime.MinValue) and safeEnd (default DateTime.UtcNow)
AuditService->>AuditLogsRepository: GetAuditLogsForDepartmentPagedAsync(safeStart,safeEnd,(int?)logType)
AuditLogsRepository->>AuditLogsRepository: Bind params as DbType.DateTime2
AuditLogsRepository->>SQLDatabase: Execute typed-parameter query
SQLDatabase-->>AuditLogsRepository: Return rows
AuditLogsRepository-->>AuditService: Return paged results
AuditService-->>Caller: Return audit logs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs (1)
69-77:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRemove the duplicate semaphore release in the fallback path.
When the first connection attempt fails and
RabbitHostname2is configured,_semaphore.Release()runs in both the innerfinally(Line 71) and outerfinally(Line 77). That over-releasesSemaphoreSlim(1,1)and can throwSemaphoreFullException, masking the original connection failure.Suggested fix
- finally - { - _semaphore.Release(); - } + finally + { + // outer finally releases the semaphore + }🤖 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 `@Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs` around lines 69 - 77, The code double-releases the SemaphoreSlim when the first connection attempt fails and RabbitHostname2 is used (both the inner finally and the outer finally call _semaphore.Release()), causing SemaphoreFullException; fix by ensuring Release is called exactly once per Acquire — either remove the duplicate outer _semaphore.Release() in the fallback path or introduce a local bool (e.g., lockTaken) set when entering the semaphore and only call _semaphore.Release() in the finally if lockTaken is true; update the connection logic around the RabbitHostname2 fallback so each semaphore Wait/Acquire is paired with a single guarded Release.
🤖 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.
Inline comments:
In `@Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs`:
- Line 185: The check if (!_connection.IsOpen) can throw NullReferenceException
when VerifyAndCreateClients(clientName) failed and _connection is null; update
the guard to first ensure _connection is not null before accessing IsOpen (e.g.,
check _connection != null && _connection.IsOpen or invert to _connection == null
|| !_connection.IsOpen), inside the RabbitConnection class method that calls
VerifyAndCreateClients(clientName) so the code safely handles a null _connection
and proceeds to create/recreate the connection only when needed.
---
Outside diff comments:
In `@Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs`:
- Around line 69-77: The code double-releases the SemaphoreSlim when the first
connection attempt fails and RabbitHostname2 is used (both the inner finally and
the outer finally call _semaphore.Release()), causing SemaphoreFullException;
fix by ensuring Release is called exactly once per Acquire — either remove the
duplicate outer _semaphore.Release() in the fallback path or introduce a local
bool (e.g., lockTaken) set when entering the semaphore and only call
_semaphore.Release() in the finally if lockTaken is true; update the connection
logic around the RabbitHostname2 fallback so each semaphore Wait/Acquire is
paired with a single guarded Release.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b80b401c-daf1-471e-8473-2b7b8519254b
📒 Files selected for processing (7)
Core/Resgrid.Services/AuditService.csProviders/Resgrid.Providers.Bus.Rabbit/RabbitConnection.csProviders/Resgrid.Providers.Bus.Rabbit/RabbitInboundQueueProvider.csProviders/Resgrid.Providers.Bus.Rabbit/RabbitOutboundQueueProvider.csProviders/Resgrid.Providers.Bus.Rabbit/RabbitTopicProvider.csRepositories/Resgrid.Repositories.DataRepository/AuditLogsRepository.csRepositories/Resgrid.Repositories.DataRepository/Stores/IdentityUserStore.cs
|
Approve |
Summary by CodeRabbit
Bug Fixes
Chores