{"record":{"id":"253d82e38c14f628","repo":"hashicorp/nomad","slug":"s-s","errorCode":null,"errorMessage":"%s: %s","messagePattern":"%s: %s","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/pluginutils/hclutils/util.go","lineNumber":222,"sourceCode":"\t\t\"max\":        stdlib.MaxFunc,\n\t\t\"min\":        stdlib.MinFunc,\n\t\t\"reverse\":    stdlib.ReverseFunc,\n\t\t\"strlen\":     stdlib.StrlenFunc,\n\t\t\"substr\":     stdlib.SubstrFunc,\n\t\t\"upper\":      stdlib.UpperFunc,\n\t}\n}\n\n// TODO: update hcl2 library with better diagnostics formatting for streamed configs\n// - should be arbitrary labels not JSON https://github.com/hashicorp/hcl2/blob/4fba5e1a75e382aed7f7a7993f2c4836a5e1cd52/hcl/json/structure.go#L66\n// - should not print diagnostic subject https://github.com/hashicorp/hcl2/blob/4fba5e1a75e382aed7f7a7993f2c4836a5e1cd52/hcl/diagnostic.go#L77\nfunc formattedDiagnosticErrors(diag hcl.Diagnostics) []error {\n\tvar errs []error\n\tfor _, d := range diag {\n\t\tif d.Summary == \"Extraneous JSON object property\" {\n\t\t\td.Summary = \"Invalid label\"\n\t\t}\n\t\terr := fmt.Errorf(\"%s: %s\", d.Summary, d.Detail)\n\t\terrs = append(errs, err)\n\t}\n\treturn errs\n}\n","sourceCodeStart":204,"sourceCodeEnd":227,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/pluginutils/hclutils/util.go#L204-L227","documentation":"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.","triggerScenarios":"ParseHclInterface returns hcl.Diagnostics (syntax errors, invalid labels, wrong attribute types, extraneous properties) and the caller formats them via formattedDiagnosticErrors.","commonSituations":"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.","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."],"exampleFix":"// before\nservice {\n  name = \"web\"\n  port \"http\"\n}\n// after\nservice {\n  name = \"web\"\n  port = \"http\"\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"if diag.HasErrors() {\n    for _, d := range diag {\n        if d.Subject != nil {\n            log.Printf(\"config error at %s: %s: %s\", d.Subject, d.Summary, d.Detail)\n        }\n    }\n}","tryCatchPattern":"val, diag := hclutils.ParseHclInterface(raw, label)\nif diag.HasErrors() {\n    for _, err := range formattedDiagnosticErrors(diag) {\n        fmt.Fprintf(os.Stderr, \"config error: %v\\n\", err)\n    }\n    os.Exit(1)\n}","preventionTips":["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"],"tags":["hcl","diagnostics","parsing","go"],"backgroundTag":"hcl-diagnostics","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"}