Skip to content

fix: routed URL host advertisement and allow-only key normalization#1683

Merged
lpcox merged 6 commits intomainfrom
fix/routed-url-host-advertisement
Mar 8, 2026
Merged

fix: routed URL host advertisement and allow-only key normalization#1683
lpcox merged 6 commits intomainfrom
fix/routed-url-host-advertisement

Conversation

@lpcox
Copy link
Collaborator

@lpcox lpcox commented Mar 8, 2026

  • Fix error messages in buildAllowOnlyPolicy to use "min-integrity" instead of "allow-only integrity"
  • All unit and integration tests pass (make agent-finished ✓)

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

lpcox and others added 2 commits March 8, 2026 14:50
When the gateway binds to 0.0.0.0 (or ::), clients cannot connect to
the advertised URLs since 0.0.0.0 is not a routable address.

Fix: In writeGatewayConfig, prefer config.Gateway.Domain if set, and
map wildcard addresses (0.0.0.0, ::) to 127.0.0.1 for client-reachable
URLs.

Also fixes TestBinaryInvocation_PipeOutput to use mock HTTP backend
instead of Docker alpine container (same pattern as other test fixes).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Change canonical JSON key from "allowonly" to "allow-only" (with dash)
across all serialization, deserialization, map lookups, error messages,
tests, and documentation.

Accept legacy "allowonly" (no dash) for backward compatibility in:
- GuardPolicy.UnmarshalJSON
- parsePolicyMap in unified.go
- buildStrictLabelAgentPayload in wasm.go

Also fix integration test timeouts in difc_config_test.go by adding
context.WithTimeout and missing apiKey in JSON stdin configs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 8, 2026 22:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes routed DIFC mode URL advertisement and guard policy key normalization to align with schema/docs, plus improves DIFC integration test robustness.

Changes:

  • Advertise client-reachable URLs by preferring gateway.domain, otherwise mapping wildcard bind hosts (0.0.0.0, ::) to 127.0.0.1.
  • Canonicalize guard policy JSON key to "allow-only" while accepting legacy "allowonly" across parsing/adaptation paths.
  • Harden DIFC integration tests with context.WithTimeout and schema-required apiKey in JSON stdin configs.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/cmd/root.go Adjusts advertised host selection for routed/unified output config (domain override + wildcard mapping).
internal/config/guard_policy.go Switches canonical JSON key to "allow-only" and accepts legacy "allowonly" on unmarshal.
internal/guard/wasm.go Updates strict policy payload validation to prefer "allow-only" with legacy fallback.
internal/server/unified.go Updates server guard policy parsing to prefer "allow-only" with legacy fallback.
internal/cmd/flags_difc.go Updates CLI help/error strings to use "allow-only" terminology.
docs/GUARD_RESPONSE_LABELING.md Updates documentation examples/field names to "allow-only" + "min-integrity".
test/integration/difc_config_test.go Adds timeouts and apiKey to avoid hangs and satisfy stdin schema validation.
test/integration/binary_test.go Makes pipe-output test Docker-free by using mock HTTP backend; tweaks timing.
test/integration/auth_config_test.go Aligns expected advertised URL host with domain-based output (localhost).
internal/server/label_agent_test.go Updates server guard policy fixture key to "allow-only".
internal/guard/guard_test.go Updates policy payload fixtures/assertions for "allow-only" key and error text.
internal/config/config_difc_test.go Updates DIFC config parsing fixtures to use "allow-only".
internal/cmd/stdout_config_test.go Adds/updates cases for wildcard mapping and domain override in advertised URLs.
internal/cmd/flags_difc_test.go Updates env var JSON fixture to use "allow-only".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 155 to 160
if integrityInput == "" {
return nil, fmt.Errorf("allowonly integrity is required")
return nil, fmt.Errorf("allow-only integrity is required")
}
if !hasIntegrity {
return nil, fmt.Errorf("allowonly integrity must be one of: none, unapproved, approved, merged")
return nil, fmt.Errorf("allow-only integrity must be one of: none, unapproved, approved, merged")
}
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new error messages in buildAllowOnlyPolicy say "allow-only integrity ...", but the flag/config field name is "min-integrity" (and the help text uses "min-integrity"). Updating these messages to consistently refer to "min-integrity" will make it clearer to users what value is missing/invalid.

See below for a potential fix:

		return nil, fmt.Errorf("min-integrity is required")
	}
	if !hasIntegrity {
		return nil, fmt.Errorf("min-integrity must be one of: none, unapproved, approved, merged")

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 94cc639. Updated both error messages in buildAllowOnlyPolicy to use "min-integrity" consistently:

  • "min-integrity is required"
  • "min-integrity must be one of: none, unapproved, approved, merged"

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
lpcox and others added 2 commits March 8, 2026 15:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Mar 8, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /tmp/go-build2640189217/b332/launcher.test /tmp/go-build2640189217/b332/launcher.test -test.testlogfile=/tmp/go-build2640189217/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true /x64=/_/GOROOT 64/src/internal/runtime/strconv/-ifaceassert 64/pkg/tool/linux_amd64/compile credential.helpe/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/compile (dns block)
    • Triggering command: /tmp/go-build2110527181/b336/launcher.test /tmp/go-build2110527181/b336/launcher.test -test.testlogfile=/tmp/go-build2110527181/b336/testlog.txt -test.paniconexit0 -test.timeout=10m0s 0189�� 06.o 0189217/b165/ fig.test --gdwarf-5 (dns block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build2640189217/b314/config.test /tmp/go-build2640189217/b314/config.test -test.testlogfile=/tmp/go-build2640189217/b314/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true go kDynw3E2y x_amd64/vet pull.rebase (dns block)
    • Triggering command: /tmp/go-build2110527181/b318/config.test /tmp/go-build2110527181/b318/config.test -test.testlogfile=/tmp/go-build2110527181/b318/testlog.txt -test.paniconexit0 -test.timeout=10m0s (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build2640189217/b332/launcher.test /tmp/go-build2640189217/b332/launcher.test -test.testlogfile=/tmp/go-build2640189217/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true /x64=/_/GOROOT 64/src/internal/runtime/strconv/-ifaceassert 64/pkg/tool/linux_amd64/compile credential.helpe/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/compile (dns block)
    • Triggering command: /tmp/go-build2110527181/b336/launcher.test /tmp/go-build2110527181/b336/launcher.test -test.testlogfile=/tmp/go-build2110527181/b336/testlog.txt -test.paniconexit0 -test.timeout=10m0s 0189�� 06.o 0189217/b165/ fig.test --gdwarf-5 (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build2640189217/b332/launcher.test /tmp/go-build2640189217/b332/launcher.test -test.testlogfile=/tmp/go-build2640189217/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true /x64=/_/GOROOT 64/src/internal/runtime/strconv/-ifaceassert 64/pkg/tool/linux_amd64/compile credential.helpe/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/compile (dns block)
    • Triggering command: /tmp/go-build2110527181/b336/launcher.test /tmp/go-build2110527181/b336/launcher.test -test.testlogfile=/tmp/go-build2110527181/b336/testlog.txt -test.paniconexit0 -test.timeout=10m0s 0189�� 06.o 0189217/b165/ fig.test --gdwarf-5 (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build2640189217/b341/mcp.test /tmp/go-build2640189217/b341/mcp.test -test.testlogfile=/tmp/go-build2640189217/b341/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/c-errorsas ln5YX_yMG 86_64/as user.name 0189217/b011/ (dns block)
    • Triggering command: /tmp/go-build2110527181/b345/mcp.test /tmp/go-build2110527181/b345/mcp.test -test.testlogfile=/tmp/go-build2110527181/b345/testlog.txt -test.paniconexit0 -test.timeout=10m0s swit�� ache/go/1.25.7/x64/src/net 0189217/b165/ 15757f40908ab992-d --gdwarf-5 ctor p=/opt/hostedtoolcache/go/1.25.7echo &#34;Build complete: awmg&#34; yE/wbOcffDfDZCJZVZqb_UU/lnjIV7nLW4n6GGWQRiRa (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of lpcox March 8, 2026 22:47
@lpcox lpcox merged commit 5f25bd4 into main Mar 8, 2026
9 checks passed
@lpcox lpcox deleted the fix/routed-url-host-advertisement branch March 8, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants