ate-env CLI root command dispatch treats unknown subcommands as <id> (exiting 0), rejects global flags before <id>, and allows creating reserved subcommand names
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 57/100
Research direction
Start with cmd/ate-env/main.go, especially newRootCommand and newGuestCommand, then inspect the built-in command definitions and the matching code in internal/apiservice/server.go. Reproduce the listed command cases and check how Cobra handles flags, unknown commands, and reserved names. Done means unknown commands fail non-zero, global flags work in the shown positions, and environment creation rejects reserved command names and invalid IDs.
Written by the indexing model from the issue text.
Description
Summary & Root Cause
The CLI decides how to parse the command line from os.Args[1] alone:
- Unknown word (
list,status,get): becomes a guest command. Without a subcommand, Cobra printsManage environment listhelp and returns success. - Flag first (
--api ...):root.Findsucceeds on the root itself, so no guest command is registered.aliceis then an unknown command at root.--apiis not a root flag anyway. - Reserved name (
delete): matches the built-in, so an environment nameddeletecannot be addressed asate-env delete shell ....CreateEnvironmentdoes not reject reserved names.
Affected Code Locations
All env citations are at 40a6c63. cmd/ate-env/main.go and internal/apiservice/server.go are identical at de462e98.
cmd/ate-env/main.go:234-262:newRootCommandcmd/ate-env/main.go:254-259: inspects onlyargs[0]and, ifroot.Findfails, registersnewGuestCommand(args[0])cmd/ate-env/main.go:43-67:newGuestCommandhas noRunEand noArgs, soate-env <word>prints its help and exits 0.--apiand--atespaceare defined only as this command's persistent flags (:66-67), not on rootcmd/ate-env/main.go:249-252: built-insmanifest,create,suspend,deletecmd/ate-env/main.go:208-232:delete <id>takescobra.ExactArgs(1)internal/apiservice/server.go:116-119:CreateEnvironmentonly checks thatidis non-empty
if len(args) > 0 {
cmdName := args[0]
if _, _, err := root.Find([]string{cmdName}); err != nil {
root.AddCommand(newGuestCommand(cmdName))
}
}
Detailed Reproduction Guide
export SUBSTRATE_ENV_API=127.0.0.1:17790 # port-forward to svc/ate-env-api
ate-env list; echo "exit: $?"
ate-env status; echo "exit: $?"
ate-env get alice; echo "exit: $?"
ate-env --api 127.0.0.1:17790 alice shell 'echo hi'; echo "exit: $?"
ate-env --atespace ate-env alice read /etc/hostname; echo "exit: $?"
ate-env create delete; echo "exit: $?"
ate-env delete shell 'echo hi'; echo "exit: $?"
Expected vs. Actual Behavior
- Expected: Unknown commands fail on stderr with a non-zero exit code. Global flags work in any position.
createrejects IDs that collide with CLI subcommands (and validates the ID format). - Actual:
list,statusandget aliceprint environment help and exit 0. Flags before<id>fail withunknown command "alice" for "ate-env".create deletesucceeds, andate-env delete shell 'echo hi'fails withaccepts 1 arg(s), received 2.
Observed Output & Logs
$ kubectl set image deploy/ate-env-api -n ate-env ate-env-api=<de462e98 api image> # rollout_rc=0, pod 1/1 Running
$ ate-env(de462e98) create compat1 # EXIT: 0
$ ate-env(de462e98) compat1 shell 'echo hi-from-de462e98' # hi-from-de462e98 / EXIT: 0
$ ate-env(de462e98) delete compat1 # EXIT: 0
$ kubectl rollout undo deploy/ate-env-api -n ate-env # back to 40a6c63 image
- Dominant language
- Go
- Stars
- 70
- Forks
- 17
- Avg merge
- 21h 36m
- Merged PRs (30d)
- 19
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from agent-substrate/env
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
agent-substrate/env#123 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 74/100
agent-substrate/env#121 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
agent-substrate/env#119 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
agent-substrate/env#118 ·
Maintainers usually reply within 1 day
-
bug substrate
Difficulty 4/5 3-5 days Newbie friendliness 35/100
agent-substrate/env#115 ·
Maintainers usually reply within 1 day
All issues in agent-substrate/env
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/arrow-swift#209 ·
Maintainers usually reply within 1 day
-
orchestrator: NFS-cache "cache path is not set" WARN logged on every build/launch instead of oncePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 65/100
influxdata/telegraf#20031 ·
Maintainers usually reply within 1 day
-
pkg/registry/file no longer builds for GOOS=windows: unguarded syscall.Stat_t in qualified_resource_migration.goPossibly taken @AnshulPatil2005 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
OneBusAway/maglev#1914 ·
Maintainers usually reply within 2 days