{"record":{"id":"59b35a9c73d3db14","repo":"wavetermdev/waveterm","slug":"cannot-specify-key-with-all","errorCode":null,"errorMessage":"cannot specify key with --all","messagePattern":"cannot specify key with --all","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-getvar.go","lineNumber":74,"sourceCode":"\t\tsendActivity(\"getvar\", WshExitCode == 0)\n\t}()\n\n\t// Resolve block to get zoneId\n\tif blockArg == \"\" {\n\t\tif getVarLocal {\n\t\t\tblockArg = \"this\"\n\t\t} else {\n\t\t\tblockArg = \"client\"\n\t\t}\n\t}\n\tfullORef, err := resolveBlockArg()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif getVarAllVars {\n\t\tif len(args) > 0 {\n\t\t\treturn fmt.Errorf(\"cannot specify key with --all\")\n\t\t}\n\t\treturn getAllVariables(fullORef.OID)\n\t}\n\n\t// Single variable case - existing logic\n\tif len(args) != 1 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"requires a key argument\")\n\t}\n\n\tkey := args[0]\n\tcommandData := wshrpc.CommandVarData{\n\t\tKey:      key,\n\t\tZoneId:   fullORef.OID,\n\t\tFileName: getVarFileName,\n\t}\n\n\tresp, err := wshclient.GetVarCommand(RpcClient, commandData, &wshrpc.RpcOpts{Timeout: 2000})","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-getvar.go#L56-L92","documentation":"wsh getvar either fetches a single variable by key or dumps all variables with --all. These two modes are mutually exclusive, so getVarRun in cmd/wshcmd-getvar.go:73 rejects any positional argument supplied alongside --all. It is a pure usage-validation error from the CLI itself, not from the RPC layer.","triggerScenarios":"Running `wsh getvar --all FOO` (or any positional key) against a resolved block/client zone while the --all flag is set.","commonSituations":"Scripting where the key is kept in a variable that is non-empty even in dump mode; copy-pasting `wsh getvar FOO` and appending --all to 'also get everything'; users misreading --all as 'also fetch this key'.","solutions":["Remove the positional key: run `wsh getvar --all` alone","If you want a single variable, drop --all: `wsh getvar FOO`","In scripts, guard the key: only pass it when not using --all, e.g. build args conditionally"],"exampleFix":"// before\nwsh getvar --all FOO\n// after\nwsh getvar --all      # dump everything\nwsh getvar FOO        # single key","handlingStrategy":"validation","validationCode":"if [ -n \"$key\" ] && $use_all; then echo 'cannot combine key with --all'; exit 2; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass a positional argument together with --all","In scripts, build the command arguments conditionally based on whether --all is set","Check `wsh getvar --help` for the mutually exclusive usage modes"],"tags":["cli","usage","wsh"],"backgroundTag":"invalid-cli-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}