Skip to content

bug(sdk/go): gateways with host-derived names (containing dots) cannot be loaded #4509

Closed

Description

@CloneOfAlex

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. Any gateway added by URL without --name is affected.

Problem Statement

openshell gateway add https://gw.example.com derives the gateway name from the host (gw.example.com). The CLI accepts any single path component as a name, but the Go SDK's validateGatewayName rejects any name containing a dot (gateway/paths.go).

Impact / Why This Matters

gateway.NewClient("gw.example.com") and gateway.LoadConfig fail with invalid gateway name: name must not contain dots; when that gateway is the active one, NewClient("") fails too, and ListGateways() silently omits it. Users must re-register gateways under a dot-free name to use the Go SDK.

Acceptance Criteria

  • The Go SDK loads, lists and resolves (as active) any gateway name the CLI can create, including host-derived names such as gw.example.com and IPv4 hosts.
  • Path traversal (.., separators) is still rejected.

Reproduction Steps

  1. openshell gateway add https://gw.example.com (or create $XDG_CONFIG_HOME/openshell/gateways/gw.example.com/metadata.json with {"gateway_endpoint":"https://gw.example.com:443","auth_mode":"none"} and active_gateway = gw.example.com).
  2. Call gateway.LoadConfig("gw.example.com"), gateway.LoadConfig(""), gateway.ListGateways().

Suggested UX (if applicable)

No response

Environment

  • OpenShell: main @ 82977e2 (2026-10-13)
  • SDK: Go (sdk/go/openshell/v1/gateway)
  • Toolchain: Go 1.25.4 linux/amd64, Node 22

Logs

gateway: invalid gateway name: name must not contain dots
gateway: no active gateway: active_gateway contains invalid name "gw.example.com": gateway: invalid gateway name: name must not contain dots
ListGateways omits the CLI-registered gateway

Activity

  1. added theissue type on Oct 13, 2026
  2. rhuss commented on Oct 14, 2026

    @rhuss
    Contributor

    📋 triage-agent

    Confirmed on main. When no name is given, the CLI derives the name from the URL host (crates/openshell-cli/src/commands/gateway.rs). Its only constraint is validated_gateway_name in crates/openshell-bootstrap/src/paths.rs: the name must be a single path component. The Go SDK's validateGatewayName (sdk/go/openshell/v1/gateway/paths.go) is stricter. It rejects any dot and anything outside [A-Za-z0-9_-], so every host-derived name fails, including IPv4 hosts. Non-loopback IPv6 hosts such as [2001:db8::1] fail for the same reason.

    The fix should make the Go SDK apply the same rule as the CLI: exactly one path component, rejecting empty names, ., .. and any separator. As with #4508, a shared set of valid and invalid name fixtures checked by both the Rust and Go tests would keep the two from drifting again.

    The report's evidence and acceptance criteria are complete. Next step: maintainer acceptance decision.

  3. sunilteja93 commented on Oct 16, 2026

    @sunilteja93
    Contributor

    Hi @rhuss ,

    I was looking into the above issue and prepared a fix for #4509 to align the Go SDK gateway name validation with the cli.

    The changes cover host derived names, active gateway resolution, gateway listing, and path traversal protection.

    All Go sdk tests passed locally (go test ./... -count=1).

    Branch: https://github.com/sunilteja93/OpenShell/tree/fix/4509-gateway-names

    Would you be open to accepting this fix? I'm also waiting on contributor vouch approval in #3827 before opening a PR.

    Thanks!

  4. rhuss commented on Oct 16, 2026

    @rhuss
    Contributor

    @sunilteja93 , thanks for jumping on this! I can give your branch a review, but I have no karma to move this issue forward (needs a state:triage-accepted label by a maintainer). This might become easier in the future when the SDK gets its own repo, but for now we need to follow the process, so I would wait with my review for the issue accepted and your PR to be vouched

    cc @johntmyers @mrunalp @sjenning ... for moving the needle 🙏

  5. sunilteja93 commented on Oct 16, 2026

    @sunilteja93
    Contributor

    Thanks @rhuss , appreciate you offering to review and looping in the maintainers. I will wait for the issue acceptance and vouch approval before opening the PR.

  6. added
    state:acceptedA maintainer decided OpenShell should pursue this issue
    and removed
    state:triage-neededOpened without agent diagnostics and needs triage
    on Oct 20, 2026
  7. TaylorMutch commented on Oct 20, 2026

    @TaylorMutch
    Collaborator

    📋 triage-agent

    Accepted for implementation. The CLI creates host-derived gateway names such as gw.example.com, while the Go SDK rejects the resulting configuration. A fix should align the SDK with the CLI for safe single-component names while continuing to reject path traversal and separators.

  8. TaylorMutch commented on Oct 20, 2026

    @TaylorMutch
    Collaborator

    @sunilteja93 I also approved your vouch request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:acceptedA maintainer decided OpenShell should pursue this issue

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions