{"record":{"id":"af00b70318086087","repo":"hashicorp/nomad","slug":"stdin-is-not-supported","errorCode":null,"errorMessage":"stdin is not supported","messagePattern":"stdin is not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/var.go","lineNumber":210,"sourceCode":"\t// Regardless of validity, make sure we make our result\n\tif b.result == nil {\n\t\tb.result = make(map[string]any)\n\t}\n\n\t// Empty strings are fine, just ignored\n\tif raw == \"\" {\n\t\treturn nil\n\t}\n\n\t// Split into key/value\n\tparts := strings.SplitN(raw, \"=\", 2)\n\n\t// If the arg is exactly \"-\", then we need to read from stdin\n\t// and merge the results into the resulting structure.\n\tif len(parts) == 1 {\n\t\tif raw == \"-\" {\n\t\t\tif b.Stdin == nil {\n\t\t\t\treturn fmt.Errorf(\"stdin is not supported\")\n\t\t\t}\n\t\t\tif b.stdin {\n\t\t\t\treturn fmt.Errorf(\"stdin already consumed\")\n\t\t\t}\n\n\t\t\tb.stdin = true\n\t\t\treturn b.addReader(b.Stdin)\n\t\t}\n\n\t\t// If the arg begins with \"@\" then we need to read a file directly\n\t\tif raw[0] == '@' {\n\t\t\tf, err := os.Open(raw[1:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdefer f.Close()\n\n\t\t\treturn b.addReader(f)","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/var.go#L192-L228","documentation":"When a KVBuilder argument is exactly '-', the builder reads the whole value from stdin. This error is thrown when the KVBuilder's Stdin field was never set, so there is no reader to consume. The library refuses to guess or fall back to os.Stdin implicitly.","triggerScenarios":"Calling KVBuilder.Add(\"-\") (or var CLI with a lone '-') on a builder constructed without assigning b.Stdin — typically when the builder is used programmatically outside the normal CLI wiring.","commonSituations":"Embedding the var parser in tests or other tools where Stdin is left nil; refactors that construct KVBuilder directly instead of through the command plumbing that wires os.Stdin in.","solutions":["Set the Stdin field on KVBuilder before calling Add, e.g. b.Stdin = os.Stdin (or a bytes.Buffer with your JSON payload)","If no stdin input is intended, pass an explicit key=value pair instead of '-'","In tests, assign a strings.Reader or bytes.Buffer to Stdin to simulate piped input"],"exampleFix":"// before\nb := &KVBuilder{Result: map[string]interface{}{}}\nb.Add(\"-\")\n// after\nb := &KVBuilder{Result: map[string]interface{}{}, Stdin: strings.NewReader(`{\"key\":\"value\"}`)}\nb.Add(\"-\")","handlingStrategy":"validation","validationCode":"if b.Stdin == nil && containsDashArg(args) {\n\tb.Stdin = os.Stdin // or strings.NewReader(jsonPayload)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always populate KVBuilder.Stdin when constructing it programmatically","Avoid '-' arguments outside real CLI contexts; pass explicit key=value instead","Use bytes.Buffer/strings.Reader in tests to simulate stdin"],"tags":["cli","stdin","configuration"],"backgroundTag":"stdin-not-supported","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}