{"record":{"id":"ef0f2dd05976bb20","repo":"hashicorp/nomad","slug":"unable-to-determine-format-of-s-use-the-in-flag","errorCode":null,"errorMessage":"Unable to determine format of %s; Use the -in flag to specify it.","messagePattern":"Unable to determine format of (.+?); Use the -in flag to specify it\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/var_put.go","lineNumber":585,"sourceCode":"\tbuilder := &KVBuilder{Stdin: stdin}\n\tif err := builder.Add(args...); err != nil {\n\t\treturn nil, err\n\t}\n\treturn builder.Map(), nil\n}\n\nfunc (c *VarPutCommand) GetConcurrentUI() cli.ConcurrentUi {\n\treturn cli.ConcurrentUi{Ui: c.Ui}\n}\n\nfunc (c *VarPutCommand) setParserForFileArg(arg string) error {\n\tswitch filepath.Ext(arg) {\n\tcase \".json\":\n\t\tc.inFmt = \"json\"\n\tcase \".hcl\":\n\t\tc.inFmt = \"hcl\"\n\tdefault:\n\t\treturn fmt.Errorf(\"Unable to determine format of %s; Use the -in flag to specify it.\", arg)\n\t}\n\treturn nil\n}\n\nfunc (c *VarPutCommand) validateInputFlag() error {\n\tswitch c.inFmt {\n\tcase \"hcl\", \"json\":\n\t\treturn nil\n\tdefault:\n\t\treturn errors.New(errInvalidInFormat)\n\t}\n}\n\nfunc (c *VarPutCommand) validateOutputFlag() error {\n\tif c.outFmt != \"go-template\" && c.tmpl != \"\" {\n\t\treturn errors.New(errUnexpectedTemplate)\n\t}\n\tswitch c.outFmt {","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/var_put.go#L567-L603","documentation":"When a `@file` argument is given without an explicit `-in` flag, setParserForFileArg infers the input format from the file extension: .json and .hcl are recognized; anything else returns `Unable to determine format of %s; Use the -in flag to specify it.` The library supports only json and hcl as input formats.","triggerScenarios":"`nomad var put @spec.txt`, `@spec.yml`, or an extension-less file, without passing `-in`; also case-mismatched extensions like `@SPEC.JSON` on case-sensitive filesystems that the code still fails to recognize.","commonSituations":"Renaming spec files to .yaml/.yml assuming YAML support; downloaded files without extensions; generated temp files with random suffixes.","solutions":["Add the explicit flag: `nomad var put -in=json @spec.txt` (or `-in=hcl` as appropriate).","Rename the file to end in .json or .hcl so inference works.","Convert unsupported formats (YAML/TOML) to JSON or HCL first."],"exampleFix":"// before\nnomad var put -path app/config @spec.yml\n// after\nyq -o=json spec.yml > spec.json && nomad var put -path app/config @spec.json","handlingStrategy":"validation","validationCode":"ext=\"${SPEC_FILE##*.}\"\ncase \"$ext\" in\n  json|hcl) ;;\n  *) echo \"unknown extension .$ext; pass -in=json or -in=hcl\" >&2; exit 2 ;;\nesac","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil && strings.Contains(err.Error(), \"Unable to determine format of\") {\n    log.Fatal(\"pass -in=json or -in=hcl explicitly for this file\")\n}","preventionTips":["Always pass -in explicitly in scripts rather than relying on extension inference.","Name spec files with .json or .hcl extensions.","Convert YAML/TOML/other formats to json or hcl before use."],"tags":["cli","nomad","flags","file-extension"],"backgroundTag":"unsupported-file-format","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"}