{"record":{"id":"6641f9a55d89e200","repo":"hashicorp/nomad","slug":"failed-to-hcl-parse-the-config-v","errorCode":null,"errorMessage":"failed to hcl parse the config: %v","messagePattern":"failed to hcl parse the config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/shared/cmd/launcher/command/device.go","lineNumber":227,"sourceCode":"\t\tApiVersion:   apiVersion,\n\t}\n\n\tif err := c.dev.SetConfig(req); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc hclConfigToAny(config []byte) (any, error) {\n\tif len(config) == 0 {\n\t\treturn map[string]any{}, nil\n\t}\n\n\t// Parse as we do in the jobspec parser\n\troot, err := hcl.Parse(string(config))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to hcl parse the config: %v\", err)\n\t}\n\n\t// Top-level item should be a list\n\tlist, ok := root.Node.(*ast.ObjectList)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"root should be an object\")\n\t}\n\n\tvar m map[string]any\n\tif err := hcl.DecodeObject(&m, list.Items[0]); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode object: %v\", err)\n\t}\n\n\treturn m[\"config\"], nil\n}\n\nfunc (c *Device) startRepl() error {\n\t// Start the output goroutine","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/plugins/shared/cmd/launcher/command/device.go#L209-L245","documentation":"Launcher config error in hclConfigToAny: the plugin config blob sent to the external device plugin is not parseable HCL, so it cannot be decoded into the map handed to the plugin's SetConfig. The offending config is the plugin config from the jobspec/client.","triggerScenarios":"setConfig receives device config bytes that fail hcl.Parse: missing braces, bad syntax, stray characters, or non-HCL content.","commonSituations":"Typos in device plugin configuration files; JSON/YAML pasted where HCL is expected; unclosed blocks or quotes; editor artifacts (smart quotes, BOM) in config files.","solutions":["Fix the HCL syntax in the device config at the line/column reported by the wrapped error.","Validate the config with an HCL linter/parser before deploying.","Ensure the config is HCL (not JSON/YAML) and free of non-ASCII/smart quotes.","Check file encoding (strip BOM) and encoding round-trips."],"exampleFix":"// before\nconfig \"mock\" {}\n  foo = \"bar\"\n// after\nconfig \"mock\" {\n  foo = \"bar\"\n}","handlingStrategy":"validation","validationCode":"// Pre-validate config parses as HCL before handing it to the device\nif _, err := hcl.Parse(string(config)); err != nil {\n\treturn fmt.Errorf(\"invalid device config HCL: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := setConfigErr; err != nil && strings.Contains(err.Error(), \"failed to hcl parse\") {\n\t// surface the hcl position info from the wrapped error to the operator\n}","preventionTips":["Lint device config files with an HCL linter in CI.","Keep configs in HCL block syntax, not JSON/YAML.","Strip BOM and smart quotes from generated configs.","Add a config validation step before applying device configuration."],"tags":["hcl","config","parsing","device"],"backgroundTag":"hcl-parse-error","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"}