[test] Add tests for config.normalizeAgentID, effectiveAgentID, and validateToolResponseFilters#7530
Merged
lpcox merged 4 commits intoJun 14, 2026
Conversation
…ToolResponseFilters
Three under-tested functions brought to 100% coverage:
- GatewayConfig.normalizeAgentID (80% → 100%)
- New: nil receiver no-op path
- New: conflict-detection path when both agent_id and api_key
are set to different values (logs deprecation + conflict warning)
- New: integration via LoadFromFile with TOML configs covering
all four combinations of the two fields
- GatewayConfig.effectiveAgentID (85.7% → 100%)
- New: nil receiver path (returns empty string)
- New: all four resolution branches (explicit, non-explicit
non-empty AgentID, APIKey fallback, zero-value)
- validateToolResponseFilters (86.7% → 100%)
- New: $ENV.KEY filter forces the gojq WithEnvironLoader
closure to execute during compilation
- New: $undefinedVar filter parses successfully but fails at
the gojq.Compile step (variable not defined error)
Overall internal/config package coverage: 97.3% → 97.6%
Overall across all testable packages: 98.3% → 98.4%
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves test coverage in internal/config by adding targeted unit/integration tests for gateway agent ID normalization/resolution and for jq tool-response-filter validation edge cases (including gojq compile-time branches).
Changes:
- Added a new test file covering
GatewayConfig.effectiveAgentID,GatewayConfig.normalizeAgentID, and severalLoadFromFileagent_id/api_key combinations. - Extended
validateToolResponseFiltersdirect-call tests to exercise the gojq environ-loader option path and the gojq compile-error (non-parse) path.
Show a summary per file
| File | Description |
|---|---|
| internal/config/validate_helpers_coverage_test.go | Adds two direct-call cases to cover gojq env-loader invocation and gojq compile-error handling in tool_response_filters validation. |
| internal/config/config_core_agent_id_coverage_test.go | New tests for agent ID precedence/normalization and TOML LoadFromFile integration coverage for agent_id/api_key combinations. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 3
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot stopped work on behalf of
lpcox due to an error
June 14, 2026 17:34
Copilot stopped work on behalf of
lpcox due to an error
June 14, 2026 17:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Coverage Improvement
Brings three under-tested
internal/configfunctions to 100% coverage.Functions Analyzed
GatewayConfig.normalizeAgentIDinternal/configGatewayConfig.effectiveAgentIDinternal/configvalidateToolResponseFiltersinternal/configWhy These Functions?
All three had the highest complexity-to-coverage gap in the
internal/configpackage — each had concrete uncovered branches containing non-trivial logic:normalizeAgentID: The conflict-detection branch (bothgateway.agent_idandgateway.api_keyset to different values) and the nil-receiver guard were both uncovered.effectiveAgentID: The nil-receiver guard was uncovered.validateToolResponseFilters: Both thegojq.WithEnvironLoaderclosure body and thegojq.Compileerror path were uncovered.Tests Added
internal/config/config_core_agent_id_coverage_test.go(new file)✅
TestEffectiveAgentID— 6 table-driven sub-cases:"")✅
TestNormalizeAgentID— 6 table-driven sub-cases:api_keyset (legacy deprecation path)agent_idset (explicit path)✅ 5
LoadFromFileintegration tests exercising all four TOML field combinations, including theagent_id/api_keyconflict path end-to-end.internal/config/validate_helpers_coverage_test.go(modified)$ENV.SOME_VARIABLEfilter — forces gojq to invoke theWithEnvironLoaderclosure during compilation, covering the env-loader branch.$undefinedVar | .fieldfilter — parses OK but fails atgojq.Compilewith "variable not defined", covering the compile-error return path.Coverage Report
Test Execution
All tests pass (run with
-tags "tty_stub testify_yaml_fail"to avoid unavailable module dependencies in the CI sandbox):gofmtandgo vetclean on all changed files.Generated by Test Coverage Improver
Next run will target the next most complex under-tested function
Warning
Firewall blocked 6 domains
The following domains were blocked by the firewall during workflow execution:
go.opentelemetry.iogo.yaml.ingolang.orggoogle.golang.orggopkg.inproxy.golang.orgSee Network Configuration for more information.