Skip to content

Global -n alias shadows subcommand --namespace (talm get -n NS fails with name-resolver error) #186

@lexfrei

Description

@lexfrei

Problem

talm get <resource> -n <namespace> --nodes $NODE --endpoints $NODE fails with:

rpc error: code = Unavailable desc = name resolver error: produced zero addresses

The short flag -n is bound to the global talm --nodes flag (pkg/commands/root.go defines -n, --nodes strings), not to the subcommand's --namespace. cobra prefers the global short alias, so -n network is parsed as --nodes=network — and network doesn't resolve to any IP, hence the gRPC name-resolver failure.

Native talosctl get uses -n for --namespace. talm reassigned -n at the global level for --nodes, causing the collision for every subcommand that natively uses -n.

Reproduction

talm get hostnames -n network --nodes $NODE --endpoints $NODE

Output:

rpc error: code = Unavailable desc = name resolver error: produced zero addresses

Workaround — use the long flag:

talm get hostnames --namespace network --nodes $NODE --endpoints $NODE

Works.

Expected

Either:

  1. Document the collision in the talm README / --help for --nodes: "Note: -n is bound globally to --nodes; use the long --namespace for subcommand namespace selection." (Cheapest fix.)
  2. Rebind the global short flag to something less common (e.g. -N) — breaking change for talm users who already script around -n.
  3. Defer the flag locally for subcommands that have their own -n — cobra supports per-subcommand short-flag rebinding; the wrapper could re-register -n as --namespace for get / logs / etc.

Option 1 is operator-friendly without breaking existing usage. Option 3 is the operator-best but more invasive.

Why this matters

get -n <ns> is the most idiomatic Talos query pattern (it's in every other doc example). Operators who paste from upstream Talos docs into a talm shell hit the wall. The error message blames DNS rather than flag collision, sending operators on a multi-minute red-herring.

Surfaced during the dev17 read-only sweep.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/commandsIssues or PRs related to pkg/commands (CLI subcommands, flag parsing, root detection)kind/bugCategorizes issue or PR as related to a bugpriority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next releasetriage/acceptedIndicates an issue is ready to be actively worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions