ate-env CLI root command dispatch treats unknown subcommands as <id> (exiting 0), rejects global flags before <id>, and allows creating reserved subcommand names
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 57/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Go
- Stelle
- 70
- Fork
- 17
- Merge medio
- 21h 36m
- PR unite (30g)
- 19
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di agent-substrate/env
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
agent-substrate/env#123 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 74/100
agent-substrate/env#121 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
agent-substrate/env#119 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
agent-substrate/env#118 ·
I maintainer di solito rispondono entro 1 giorno
-
bug substrate
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
agent-substrate/env#115 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di agent-substrate/env
Issue simili
-
area: frontend priority: normal
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
TestAutonomousStop_ReportsObservedState fails under host load: 1s wall-clock ceiling vs 250ms cycleApertatype:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
nightgauge/nightgauge#2909 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
jasonfen/terminal-space-program#842 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MustacheCase/zanadir#521 ·
I maintainer di solito rispondono entro 1 giorno
-
v3.1.0: spread placement groups fail — label key uses the reserved hetzner.cloud prefixForse già presa @ScrimReaper l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
stubbi/karpenter-provider-hetzner#120 ·
I maintainer di solito rispondono entro 4 giorni