fix: register guard test uses non-noop guard for policy validation#2273
Merged
Conversation
TestRegisterGuard_InvalidPolicy_ReturnsError was failing because it used a noop guard type. requireGuardPolicyIfGuardEnabled intentionally short-circuits for noop guards (g.Name() == "noop") without validating the policy. Changed the test to register a non-noop guard type (write-sink) so the invalid global policy validation path is exercised. Also fixed gofmt whitespace alignment in proxy_test.go. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a failing guard registration unit test by ensuring the test exercises the intended policy-validation path (which is skipped for noop guards by design).
Changes:
- Update
TestRegisterGuard_InvalidPolicy_ReturnsErrorto register and use a non-noop guard type so invalid global guard policy validation is reached. - Add clarifying test comment explaining the noop short-circuit behavior.
- Apply a minor gofmt alignment fix in
proxy_test.go.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/server/register_guard_test.go | Adjusts the invalid-policy test setup to use a non-noop guard type so requireGuardPolicyIfGuardEnabled triggers resolveGuardPolicy validation. |
| internal/proxy/proxy_test.go | Fixes whitespace alignment in a response header map literal (gofmt-style). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Mar 21, 2026
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.
Problem
TestRegisterGuard_InvalidPolicy_ReturnsErrorwas failing on main because it used anoopguard type.requireGuardPolicyIfGuardEnabledintentionally short-circuits for noop guards (g.Name() == "noop") without validating the policy — this is by design (documented in the companion testTestRegisterGuard_GuardConfigFound_NoopType_GlobalAllowOnlyPolicy).Fix
write-sinkviaguard.RegisterGuardType) so the invalid global policy validation path is actually exercisedproxy_test.goTesting
make agent-finishedpasses — all unit and integration tests green.