Refactor duplicate validation into shared utility - #12236
Conversation
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The focused refactor preserves validation behavior and includes appropriate utility coverage.
Pull request overview
Adds a generic duplicate-detection utility and applies it to configuration validation.
Changes:
- Introduces and tests
util.FindDuplicate. - Refactors gateway agent ID and agent-policy duplicate validation.
- Preserves existing validation errors and normalized values.
File summaries
| File | Description |
|---|---|
internal/util/collections.go |
Adds the generic duplicate helper. |
internal/util/collections_test.go |
Covers duplicate and no-duplicate cases. |
internal/config/validation_gateway.go |
Uses the helper for agent IDs. |
internal/config/agent_policy.go |
Uses the helper for servers and tools. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No write leaked through any surface. No FAIL conditions observed.
|
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No write leaked. No objects were created.
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked in any part. The enforcement holds, but the methodology gaps above mean gateway-level write blocking cannot be independently confirmed for this run.
|
Duplicate detection was reimplemented across configuration validators. This adds a reusable generic helper and migrates the agent-policy and gateway agent-ID paths.
util.FindDuplicate[T comparable]to return the first repeated value.Validation migration
Coverage