[Repo Assist] refactor(config): extract shared non-empty string slice validator - #12158
Conversation
Consolidates validateAgentIDs and validateTrustedBots onto a single validateNonEmptyStringSlice helper in validation_rules.go, removing duplicated 'non-empty array of non-empty strings' logic identified in issue #12143. ValidateStringArrayField in guard_policy_validation.go was left unchanged since it operates on []interface{} (not []string) and its distinct error-message wording is pinned by existing tests. Closes #12143 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The focused refactor preserves existing validation semantics and error wording without introducing unresolved issues.
Pull request overview
This PR centralizes repeated non-empty string-slice validation while preserving existing behavior and error messages.
Changes:
- Adds a shared
validateNonEmptyStringSlicehelper. - Delegates agent ID and trusted-bot validation to the helper.
File summaries
| File | Description |
|---|---|
internal/config/validation_rules.go |
Adds the shared validation rule. |
internal/config/validation_gateway.go |
Reuses the rule for both fields. |
Review details
- Files reviewed: 2/2 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 — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked in any part. The result is INCONCLUSIVE (not FAIL) because enforcement gaps exist in the test methodology: write tools absent from catalog (Part B) and unauthenticated gh (Parts D/E) mean the gateway's own independent enforcement layer was not directly exercised in this run. References: §33312828392
|
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked. No Part B, D, or E operation succeeded.
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked in any part. Reads all succeeded. References: §33312828336
|
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Partial fix for duplicate-code finding #12143 (recommendation 1):
validateAgentIDsandvalidateTrustedBotsininternal/config/validation_gateway.goindependently re-implemented the same "non-empty array of non-empty strings" validation logic with slightly different signatures.Change
validateNonEmptyStringSlice(values []string, defined bool, fieldName, specSuffix string) errortointernal/config/validation_rules.goas the single source of truth for this rule.validateAgentIDsandvalidateTrustedBotsto delegate to the new helper, preserving their exact existing error-message wording (verified againstvalidation_gateway_coverage_test.goandconfig_stdin_test.go).Scope note
I intentionally left
ValidateStringArrayFieldininternal/config/guard_policy_validation.go(recommendation 2 in #12143) unchanged. It operates on[]interface{}rather than[]stringand its error messages ("invalid %s value: ...") are pinned by an extensive existing test suite (guard_policy_string_validation_test.go). Bridging it onto the same helper would require changing those user-facing error strings, which felt out of scope for a "clearly beneficial, low-risk" improvement — happy to revisit if maintainers want that follow-up too.Test Status
go build ./...— passgo vet ./...— passgofmt -l .— no diffsgo test ./...(all packages, unit) — passgo test ./test/integration/...(binary built viamake build) — pass (46.8s)gofmt/go vetas a fallback.Closes #12143
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
api.github.com[!TIP]
api.github.comis blocked because GitHub API access uses the built-in GitHub tools by default. Instead of addingapi.github.comtonetwork.allowed, usetools.github.mode: gh-proxyfor direct pre-authenticated GitHub CLI access without requiring network access toapi.github.com:See GitHub Tools for more information on
gh-proxymode.To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run