Skip to content

ax get plural with name ignores name and lists instead of getting #383

Description

@HoneyTyagii

What happened?

ax get tasks mytask (plural plus name, the kubectl style) lists all tasks instead of showing mytask. Same for gateways, workspaces, models.

Repro

ax get tasks mytask
# expected: YAML for task `mytask` (like `ax get task mytask`)
# actual: table output of all tasks, `mytask` arg silently ignored

Same with:

  • ax get gateways my-gw vs ax get gateway my-gw
  • ax get workspaces my-ws vs ax get workspace my-ws
  • ax get models my-model vs ax get model my-model

Root cause

In cmd/ax/main.go:356,415,474,519, && binds tighter than || in Go:

if resource == "tasks" || resource == "task" && len(args) == 1 {

This parses as resource=="tasks" || (resource=="task" && len==1), so any plural form always takes the list branch even when len(args)==2. The get-one branch below is then unreachable for plurals:

if (resource == "task" || resource == "tasks") && len(args) >= 2 {

Affected lines:

  • cmd/ax/main.go:356 for tasks
  • cmd/ax/main.go:415 for gateways
  • cmd/ax/main.go:474 for workspaces
  • cmd/ax/main.go:519 for models

Expected

Both singular and plural plus name should get one resource:
ax get tasks mytask should equal ax get task mytask.

Suggested fix

Parenthesize in all 4 places:

if (resource == "tasks" || resource == "task") && len(args) == 1 {

Checked

Searched open issues (36 open). Covers ax ssh --help (#373) and ax ssh no-command (#374) but no get precedence bug.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions