fix(AgentController): case-insensitive agentId filtering and null-guard for GetRuleTriggers#1343
Conversation
Review Summary by QodoAdd case-insensitive agent filtering to rule triggers endpoint
WalkthroughsDescription• Add optional agentId route parameter to filter rule triggers • Implement case-insensitive agent ID matching using StringComparer.OrdinalIgnoreCase • Add null-guard to handle empty/whitespace agentId values safely • Introduce AgentIds property to IRuleTrigger interface for UI filtering Diagramflowchart LR
A["IRuleTrigger interface"] -->|"Add AgentIds property"| B["AgentIds: string[]?"]
C["GET /rule/triggers/{agentId}"] -->|"New endpoint"| D["Filter triggers by agentId"]
D -->|"Case-insensitive match"| E["StringComparer.OrdinalIgnoreCase"]
D -->|"Null-guard check"| F["IsNullOrWhiteSpace validation"]
F -->|"If empty"| G["Return all triggers"]
F -->|"If valid"| H["Filter by AgentIds"]
File Changes1. src/Infrastructure/BotSharp.Abstraction/Rules/IRuleTrigger.cs
|
Code Review by Qodo
1.
|
Summary
Hardens the new
GET /rule/triggers/{agentId}endpoint inAgentController.Rule.csso that:agentIdroute parameter is matched case-insensitively againstIRuleTrigger.AgentIds.agentIdvalues no longer cause a silent over-restrictive filter; the endpoint now falls back to returning all registered triggers.Motivation
agentIdis an identifier and should behave consistently regardless of casing supplied by the caller. The previous implementation used the defaultIEnumerable<string>.Containsoverload, which performs an ordinal, case-sensitive comparison and could exclude valid triggers depending on how the caller cased the route segment.agentId. An empty/whitespace value would be passed straight into theWhere(...)filter and would almost certainly match nothing, producing a misleading empty result instead of a safe, predictable response.Changes
src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.csx.AgentIds.Contains(agentId, StringComparer.OrdinalIgnoreCase)so identifier matching is ordinal and case-insensitive.string.IsNullOrWhiteSpace(agentId)guard; when the parameter is missing or blank, the agent filter is skipped and all triggers are returned (consistent with the parameterlessGET /rule/triggersoverload).Risk / Compatibility