Commit dc91207
authored
[Repo Assist] refactor(config): extract shared non-empty string slice validator (#12158)
🤖 *This PR was created by Repo Assist, an automated AI assistant.*
## Summary
Partial fix for duplicate-code finding #12143 (recommendation 1):
`validateAgentIDs` and `validateTrustedBots` in
`internal/config/validation_gateway.go` independently re-implemented the
same "non-empty array of non-empty strings" validation logic with
slightly different signatures.
## Change
- Added `validateNonEmptyStringSlice(values []string, defined bool,
fieldName, specSuffix string) error` to
`internal/config/validation_rules.go` as the single source of truth for
this rule.
- Rewired `validateAgentIDs` and `validateTrustedBots` to delegate to
the new helper, preserving their exact existing error-message wording
(verified against `validation_gateway_coverage_test.go` and
`config_stdin_test.go`).
## Scope note
I intentionally left `ValidateStringArrayField` in
`internal/config/guard_policy_validation.go` (recommendation 2 in
#12143) unchanged. It operates on `[]interface{}` rather than `[]string`
and 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 ./...` — pass
- `go vet ./...` — pass
- `gofmt -l .` — no diffs
- `go test ./...` (all packages, unit) — pass
- `go test ./test/integration/...` (binary built via `make build`) —
pass (46.8s)
- golangci-lint not available in this sandbox; relied on `gofmt`/`go
vet` as a fallback.
Closes #12143
> [!WARNING]
> <details>
> <summary>Firewall blocked 1 domain</summary>
>
> The following domain was blocked by the firewall during workflow
execution:
>
> - `api.github.com`
>
> [!TIP]
> `api.github.com` is blocked because GitHub API access uses the
built-in GitHub tools by default. Instead of adding `api.github.com` to
`network.allowed`, use `tools.github.mode: gh-proxy` for direct
pre-authenticated GitHub CLI access without requiring network access to
`api.github.com`:
>
> ```yaml
> tools:
> github:
> mode: gh-proxy
> ```
>
> See [GitHub
Tools](https://github.github.com/gh-aw/reference/github-tools/) for more
information on `gh-proxy` mode.
>
> To allow these domains, add them to the `network.allowed` list in your
workflow frontmatter:
>
> ```yaml
> network:
> allowed:
> - defaults
> - "api.github.com"
> ```
>
> See [Network
Configuration](https://github.github.com/gh-aw/reference/network/) for
more information.
>
> </details>
> Generated by [Repo
Assist](https://github.com/github/gh-aw-mcpg/actions/runs/33312260725) ·
copilot · auto · 182.5 AIC · ⊞ 18.9K ·
[◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+repo-assist%22&type=pullrequests)
> <sub>Comment <em>/repo-assist</em> to run again</sub>
>
<details>
<summary><sub>Add this agentic workflow to your repo</sub></summary>
To install this agentic workflow, run
```
gh aw add githubnext/agentics@851905c
```
</details>
<!-- gh-aw-agentic-workflow: Repo Assist, engine: copilot, model: auto,
id: 33312260725, workflow_id: repo-assist, run:
https://github.com/github/gh-aw-mcpg/actions/runs/33312260725 -->
<!-- gh-aw-workflow-id: repo-assist -->
<!-- gh-aw-workflow-call-id: github/gh-aw-mcpg/repo-assist -->2 files changed
Lines changed: 22 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 107 | + | |
119 | 108 | | |
120 | 109 | | |
121 | 110 | | |
| |||
136 | 125 | | |
137 | 126 | | |
138 | 127 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 128 | + | |
151 | 129 | | |
152 | 130 | | |
153 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
35 | 55 | | |
36 | 56 | | |
37 | 57 | | |
| |||
0 commit comments