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.
What happened?
ax get tasks mytask(plural plus name, the kubectl style) lists all tasks instead of showingmytask. Same forgateways,workspaces,models.Repro
Same with:
ax get gateways my-gwvsax get gateway my-gwax get workspaces my-wsvsax get workspace my-wsax get models my-modelvsax get model my-modelRoot cause
In
cmd/ax/main.go:356,415,474,519,&&binds tighter than||in Go:This parses as
resource=="tasks" || (resource=="task" && len==1), so any plural form always takes the list branch even whenlen(args)==2. The get-one branch below is then unreachable for plurals:Affected lines:
cmd/ax/main.go:356for taskscmd/ax/main.go:415for gatewayscmd/ax/main.go:474for workspacescmd/ax/main.go:519for modelsExpected
Both singular and plural plus name should get one resource:
ax get tasks mytaskshould equalax get task mytask.Suggested fix
Parenthesize in all 4 places:
Checked
Searched open issues (36 open). Covers
ax ssh --help(#373) andax sshno-command (#374) but no get precedence bug.