bug(sdk/go): no system-level active gateway fallback; OPENSHELL_SYSTEM_GATEWAY_DIR ignored #4517
Description
User Story
I use OpenShell and build automation against its SDKs. While reviewing sdk/ I hit this behavior and reproduced it with the minimal test below against main.
Problem Statement
The CLI falls back to the system active_gateway under /etc/openshell (or $OPENSHELL_SYSTEM_GATEWAY_DIR) when no user active_gateway exists, and honors that variable for the system gateways directory. The Go SDK reads only the user active_gateway and hardcodes /etc/openshell.
Impact / Why This Matters
On machines provisioned with system-level gateway config, gateway.NewClient("") fails with no active gateway although the CLI works, and an overridden system directory is invisible to the SDK.
Acceptance Criteria
- The Go SDK resolves the active gateway and system gateways the same way as the CLI, including
OPENSHELL_SYSTEM_GATEWAY_DIR.
Reproduction Steps
Set XDG_CONFIG_HOME to an empty dir and OPENSHELL_SYSTEM_GATEWAY_DIR to a dir containing gateways/corp/metadata.json and active_gateway = corp; gateway.LoadConfig("") fails.
Suggested UX (if applicable)
No response
Environment
- OpenShell:
main@ 82977e2 (2026-10-13) - SDK: Go (
sdk/go/openshell/v1/gateway/paths.go) - Toolchain: Go 1.25.4 linux/amd64, Node 22
Logs
BUG: system active gateway not resolved: gateway: no active gateway
Activity
rhuss commentedon Oct 14, 2026
Thanks for the report.
Partially fixed on current
main. Since #4106 (6e69360, merged after the commit you tested),systemConfigDir()insdk/go/openshell/v1/gateway/paths.gohonorsOPENSHELL_SYSTEM_GATEWAY_DIRand ignores empty and relative values, matching the CLI.The active-gateway fallback is still missing.
resolveActiveGateway()reads only the useractive_gatewayfile, while the CLI'sload_active_gateway()(crates/openshell-bootstrap/src/metadata.rs) falls back to<system dir>/active_gatewaywhen the user file is absent. The CLI also skips an invalid user entry and falls back to the system one (load_active_gateway_ignores_invalid_user_name_and_falls_back_to_system), so the Go fix should match that too. Note that #4509 affects the same function: a host-derived system gateway name with dots would still be rejected after this fix.The remaining acceptance criterion is the active-gateway fallback. Next step: maintainer acceptance decision.