hashicorp/nomad · error
%s: %s
Error message
%s: %s
What it means
formattedDiagnosticErrors converts hcl.Diagnostics into []error, formatting each diagnostic as "Summary: Detail". It rewrites the confusing 'Extraneous JSON object property' summary to 'Invalid label' before formatting, since Nomad parses HCL-shaped config through a JSON body in some paths.
Source
Thrown at helper/pluginutils/hclutils/util.go:222
"max": stdlib.MaxFunc,
"min": stdlib.MinFunc,
"reverse": stdlib.ReverseFunc,
"strlen": stdlib.StrlenFunc,
"substr": stdlib.SubstrFunc,
"upper": stdlib.UpperFunc,
}
}
// TODO: update hcl2 library with better diagnostics formatting for streamed configs
// - should be arbitrary labels not JSON https://github.com/hashicorp/hcl2/blob/4fba5e1a75e382aed7f7a7993f2c4836a5e1cd52/hcl/json/structure.go#L66
// - should not print diagnostic subject https://github.com/hashicorp/hcl2/blob/4fba5e1a75e382aed7f7a7993f2c4836a5e1cd52/hcl/diagnostic.go#L77
func formattedDiagnosticErrors(diag hcl.Diagnostics) []error {
var errs []error
for _, d := range diag {
if d.Summary == "Extraneous JSON object property" {
d.Summary = "Invalid label"
}
err := fmt.Errorf("%s: %s", d.Summary, d.Detail)
errs = append(errs, err)
}
return errs
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Read the 'Summary: Detail' message; fix the HCL at the file:position given in the Detail.
- For 'Invalid label', correct the block label name to one the schema accepts.
- For type/detail complaints, fix the attribute value type (quote strings, unquote numbers) in the config.
- Validate the config with a smaller snippet/isolated stanza to pinpoint the offending block.
Example fix
// before
service {
name = "web"
port "http"
}
// after
service {
name = "web"
port = "http"
} Defensive patterns
Strategy: try-catch
Type guard
if diag.HasErrors() {
for _, d := range diag {
if d.Subject != nil {
log.Printf("config error at %s: %s: %s", d.Subject, d.Summary, d.Detail)
}
}
} Try / catch
val, diag := hclutils.ParseHclInterface(raw, label)
if diag.HasErrors() {
for _, err := range formattedDiagnosticErrors(diag) {
fmt.Fprintf(os.Stderr, "config error: %v\n", err)
}
os.Exit(1)
} Prevention
- Lint HCL/JSON config in CI before deployment
- Keep block labels and attribute types matching the schema
- Print diagnostic Subject positions so users can locate the error
- Test configs with 'nomad validate' or equivalent before applying
When it happens
Trigger: ParseHclInterface returns hcl.Diagnostics (syntax errors, invalid labels, wrong attribute types, extraneous properties) and the caller formats them via formattedDiagnosticErrors.
Common situations: Malformed HCL/JSON config blocks: wrong label usage, duplicate or unknown attributes, type mismatches (e.g. string where number expected) when parsing job, plugin or nested stanza definitions.
Related errors
- users: unable to parse uid/gid from username
- <combined HCL diagnostics from str.String()>
- Failed to parse ACL Policy: %v
- error parsing HTTPMaxSize: %w
- error parsing GCSTimeout: %w
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/253d82e38c14f628.
Report an issue: GitHub.