{"record":{"id":"240f755440946789","repo":"hashicorp/nomad","slug":"unknown-format-flag-value","errorCode":null,"errorMessage":"unknown format flag value","messagePattern":"unknown format flag value","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/var_put.go","lineNumber":436,"sourceCode":"\n\tswitch c.inFmt {\n\tcase \"json\":\n\t\terr = json.Unmarshal(c.contents, out)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error unmarshaling json: %w\", err)\n\t\t}\n\tcase \"hcl\":\n\t\tout, err = parseVariableSpec(c.contents, c.verbose)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error parsing hcl: %w\", err)\n\t\t}\n\tcase \"\":\n\t\treturn nil, errors.New(\"format flag required\")\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown format flag value\")\n\t}\n\n\t// It is possible a specification file was used which did not declare any\n\t// items. Therefore, default the entry to avoid panics and ensure this type\n\t// of use is valid.\n\tif out.Items == nil {\n\t\tout.Items = make(map[string]string)\n\t}\n\n\t// Handle cases where values are provided by CLI flags that modify the\n\t// the created variable. Typical of a \"copy\" operation, it is a convenience\n\t// to reset the Create and Modify metadata to zero.\n\tvar resetIndex bool\n\n\t// Step on the namespace in the object if one is provided by flag\n\tif c.Meta.namespace != \"\" && c.Meta.namespace != out.Namespace {\n\t\tout.Namespace = c.Meta.namespace\n\t\tresetIndex = true\n\t}\n\n\t// Step on the path in the object if one is provided by argument.","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/var_put.go#L418-L454","documentation":"makeVariable validates the `-in` format flag with a switch over json/hcl/empty. Any value other than those (a mistyped format string) falls into the default branch and yields `unknown format flag value`. Note this message carries no wrapped detail, so it indicates purely an unsupported flag value.","triggerScenarios":"`nomad var put -in=yaml @file`, `-in=JSON` (wrong case or an unsupported spelling), or scripts templating a format variable that contains an invalid value.","commonSituations":"Assuming YAML or TOML input is supported (only json and hcl are); uppercase format values in CI config; typos like `-in=jason`.","solutions":["Use exactly `-in=json` or `-in=hcl` (lowercase).","Convert YAML/TOML specs to JSON or HCL before passing them to nomad.","Check the templated/CI variable that supplies the format value for stray whitespace or case issues."],"exampleFix":"// before\nnomad var put -in=yaml @spec.yaml\n// after\nyq -o=json spec.yaml > spec.json && nomad var put -in=json @spec.json","handlingStrategy":"validation","validationCode":"case \"${IN_FMT:-}\" in\n  json|hcl|\"\") ;;\n  *) echo \"-in must be json or hcl, got: ${IN_FMT}\" >&2; exit 2 ;;\nesac","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil && err.Error() == \"unknown format flag value\" {\n    log.Fatal(\"-in must be exactly 'json' or 'hcl' (lowercase)\")\n}","preventionTips":["Hardcode lowercase 'json'/'hcl' in scripts, never template raw user input into -in.","Remember only json and hcl are supported — convert YAML/TOML upstream.","Trim whitespace from variables feeding the -in flag."],"tags":["cli","nomad","flags","validation"],"backgroundTag":"invalid-flag-value","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"}