hashicorp/nomad · error
Unable to determine format of %s; Use the -in flag to specif
Error message
Unable to determine format of %s; Use the -in flag to specify it.
What it means
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.
Source
Thrown at command/var_put.go:585
builder := &KVBuilder{Stdin: stdin}
if err := builder.Add(args...); err != nil {
return nil, err
}
return builder.Map(), nil
}
func (c *VarPutCommand) GetConcurrentUI() cli.ConcurrentUi {
return cli.ConcurrentUi{Ui: c.Ui}
}
func (c *VarPutCommand) setParserForFileArg(arg string) error {
switch filepath.Ext(arg) {
case ".json":
c.inFmt = "json"
case ".hcl":
c.inFmt = "hcl"
default:
return fmt.Errorf("Unable to determine format of %s; Use the -in flag to specify it.", arg)
}
return nil
}
func (c *VarPutCommand) validateInputFlag() error {
switch c.inFmt {
case "hcl", "json":
return nil
default:
return errors.New(errInvalidInFormat)
}
}
func (c *VarPutCommand) validateOutputFlag() error {
if c.outFmt != "go-template" && c.tmpl != "" {
return errors.New(errUnexpectedTemplate)
}
switch c.outFmt {View on GitHub (pinned to 482b49bf1a)
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.
Example fix
// before nomad var put -path app/config @spec.yml // after yq -o=json spec.yml > spec.json && nomad var put -path app/config @spec.json
Defensive patterns
Strategy: validation
Validate before calling
ext="${SPEC_FILE##*.}"
case "$ext" in
json|hcl) ;;
*) echo "unknown extension .$ext; pass -in=json or -in=hcl" >&2; exit 2 ;;
esac Try / catch
if err := run(); err != nil && strings.Contains(err.Error(), "Unable to determine format of") {
log.Fatal("pass -in=json or -in=hcl explicitly for this file")
} Prevention
- 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.
When it happens
Trigger: `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.
Common situations: Renaming spec files to .yaml/.yml assuming YAML support; downloaded files without extensions; generated temp files with random suffixes.
Related errors
- unknown format flag value
- both -n and -c set
- evaluation ID or filter flag required
- The '-template' flag is only valid when using 'go-template'
- A template must be supplied using '-template' when using go-
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/ef0f2dd05976bb20.
Report an issue: GitHub.