hashicorp/nomad · error
Invalid value for "-in"; valid values are [hcl, json]
Error message
Invalid value for "-in"; valid values are [hcl, json]
What it means
Returned by VarPutCommand.validateInputFlag when the -in flag (or a file extension that could not be inferred) is neither "hcl" nor "json". The sentinel errInvalidInFormat marks an unusable input format for the variable payload.
Source
Thrown at command/var_put.go:595
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 {
case "none", "json", "hcl", "table":
return nil
case "go-template":
if c.tmpl == "" {
return errors.New(errMissingTemplate)
}
return nil
default:
return errors.New(errInvalidOutFormat)
}View on GitHub (pinned to 482b49bf1a)
Solutions
- Use -in=hcl or -in=json (lowercase)
- Convert yaml/toml input to json or hcl before invoking
- Fix spelling/case of the -in value
Example fix
// before vault kv put -in=yaml secret/foo @spec.yaml // after vault kv put -in=json secret/foo @spec.json
Defensive patterns
Strategy: validation
Validate before calling
if inFmt != "hcl" && inFmt != "json" {
return fmt.Errorf("invalid -in %q; must be hcl or json", inFmt)
} Try / catch
if err := cmd.validateInputFlag(); err != nil {
if strings.Contains(err.Error(), "Invalid value for \"-in\"") {
// convert input to json/hcl and retry
}
return err
} Prevention
- Only hcl and json are accepted; convert yaml/toml beforehand
- Lowercase the value in wrappers
- Use shell completion to avoid typos
When it happens
Trigger: Running `vault kv put -in=yaml|toml|text ...` or a misspelled value like -in=HCL.
Common situations: Assuming yaml input is supported; case-sensitivity mistakes; scripts generated with wrong format names.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- The '-template' flag is only valid when using 'go-template'
- A template must be supplied using '-template' when using go-
- Invalid value for "-out"; valid values are [go-template, hcl
- 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/f183a536a78cbe00.
Report an issue: GitHub.