Repository navigation
fix(sdk/go): fall back to system active gateway - #4917
TaylorMutch merged 2 commits into
Conversation
Match the CLI: use the system active_gateway when the user one is missing or invalid. Signed-off-by: Eric Curtin <eric.curtin@docker.com>
|
@TaylorMutch @SDAChess could you please triage #4517 so the issue check can pass? PTAL, and |
|
@krishicks @mrunalp could you please accept #4517 so the issue check can pass? PTAL, and |
|
Heads-up: the Go SDK moves to ai-openshell/sdk-go on 2026-11-03 (details in #5031). For this PR that means:
Nothing to do on your side either way. cc @TaylorMutch, a review by Monday 2026-11-02 would let this land in core. |
|
The Go SDK freeze is tomorrow, Tuesday 2026-11-03, at the end of the day (#5031). This fix is small and SDK-only, so it would be good to land it in core before then. Two things block it:
@TaylorMutch @pimlock, could one of you accept the issue and review? If it doesn't make it, it gets ported to ai-openshell/sdk-go with the original commits, as announced above. |
|
/ok to test 3ded94f |
rhuss
left a comment
There was a problem hiding this comment.
cc-review Summary
Thanks for this fix, Eric. The change is small, follows the CLI's load_active_gateway closely, and the new tests are hermetic against a real /etc/openshell on the host.
This is an agent-assisted review: several reviewer agents read the diff and I curated their findings. Any scenarios below were derived from reading the code and were not executed. Everything here is a non-blocking suggestion (Minor or Notable), so none of it needs to hold the PR. Once you have had a look, this seems ready for a maintainer.
What Went Well
paths.goreadActiveGatewayFile(lines 161-178): one shared reader applies the same trim, empty check andvalidateGatewayNameto both files, so a value like../escapein the system file cannot traverse out of the gateways directory.paths.goresolveActiveGateway(lines 144-159): the user-then-system order mirrorsload_active_gatewayincrates/openshell-bootstrap/src/metadata.rs, including the invalid-user fallback asked for in the triage of #4517.paths.goline 155: reusingsystemConfigDir()means theOPENSHELL_SYSTEM_GATEWAY_DIRoverride and its empty/relative rejection apply to the active gateway lookup exactly as they do to gateway directories.paths_test.goandgateway_test.go: the no-active-gateway tests now pinOPENSHELL_SYSTEM_GATEWAY_DIRto a temp dir, andTestResolveActiveGateway_PrefersUserwrites different names to both files, so it checks precedence rather than mere presence.gateway_test.goTestLoadConfig_SystemActiveGateway(line 398): an end-to-end check of the reproduction from #4517 through the publicLoadConfig, asserting bothNameandSource == SourceSystem.
Findings
| Severity | File | Description | Source |
|---|---|---|---|
| Minor | sdk/go/openshell/v1/gateway/paths.go:150 |
A CLI-valid but Go-invalid user name silently falls back to the system gateway | gator |
| Minor | sdk/go/openshell/v1/gateway/paths.go:155 |
A rejected system active_gateway is not mentioned in the returned error |
production |
| Minor | sdk/go/openshell/v1/gateway/paths.go:146 |
No test for the userConfigDir() error branch falling back to the system file |
test-quality |
| Minor | sdk/go/openshell/v1/gateway/gateway_test.go:398 |
No test for ListGateways marking a system-default gateway as Active |
test-quality |
| Minor | sdk/go/openshell/v1/gateway/paths_test.go:265 |
InvalidSystemIsIgnored does not check that the error describes the user file |
test-quality |
| Notable | sdk/go/openshell/v1/gateway/gateway.go:120 |
ListGateways now reports a system-default gateway as Active (summary only) |
goal-alignment |
The comments on paths.go:155 and paths_test.go:265 pull in opposite directions (surface the system error, or pin the user-only error). Either choice is fine; the point is to pick one and pin it with a test.
Not posted inline (the location, gateway.go line 120, is outside the PR diff):
- Notable:
ListGatewayscallsresolveActiveGateway, so with only a systemactive_gatewayit now returns that gateway withActive: true(before this PR it wasfalse). This matches the CLI'sgateway listand the existingInfo.Activedoc ("whether this is the currently active gateway"), so the behavior itself looks right. A one-line mention in the PR description (and optionally in theListGatewaysdoc comment) would help consumers who readActiveas "explicitly selected by the user". The matching test gap is in thegateway_test.go:398comment. Source: goal-alignment agent
Review Details
- Findings posted: 6 (5 inline, 1 in this summary)
- Findings reviewed and not posted: 0
- Gate outcome: PASS (no Critical or Important findings)
- Participating reviewers: gator, production, test-quality, goal-alignment (architecture, correctness and security also ran and reported no findings)
PR Review StatusThe independent code review found no blocking defects. The Go SDK now tries the user active gateway before the system default, validates both names through the same reader, and tests fallback, user precedence, invalid entries, and system-backed @ericcurtin, I checked your request to accept #4517 and start CI: the issue now has Action required: a maintainer must approve the Trivy Changes run, which is awaiting workflow approval, and rerun PR Issue Acceptance. For the changed SDK gateway-selection behavior, please add a short explanation to Blocking code findings: None. Carried findings: None. Gator metadata
|
Signed-off-by: Eric Curtin <eric.curtin@docker.com>
|
Pushed 017959a: pinned the user-file error contract, added the three requested tests (shared helper), noted |
|
Follow-up on my review: I checked the current head (
Ready for a maintainer review. |
|
@TaylorMutch @purp Addressed the review comments in 017959a, and the Go SDK freeze is today. PTAL, and |
|
/ok to test 017959a |
TaylorMutch
left a comment
There was a problem hiding this comment.
Reviewed active gateway fallback against the CLI and checked user precedence, validation, error handling, and listing. No blocking findings. The gateway package passed three times with the race detector. Required Branch Checks are still pending.
Summary
Fall back to the system
active_gatewaywhen the user one is missing or invalid, like the CLI.Related Issue
Closes #4517
Changes
resolveActiveGatewaytries the user file, then<system dir>/active_gateway.ListGatewaysnow marks the system default asActive./etc/openshell.Testing
Ran
go test ./...andgolangci-lint runinsdk/go.Checklist