{"record":{"id":"e0b8692288872c8f","repo":"mikefarah/yq","slug":"hcl-parse-error-w","errorCode":null,"errorMessage":"hcl parse error: %w","messagePattern":"hcl parse error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/decoder_hcl.go","lineNumber":118,"sourceCode":"\t\tfor i >= 0 && (src[i] == ' ' || src[i] == '\\t' || src[i] == '\\n' || src[i] == '\\r') {\n\t\t\ti--\n\t\t}\n\t}\n\n\tif len(comments) > 0 {\n\t\treturn strings.Join(comments, \"\\n\")\n\t}\n\treturn \"\"\n}\n\nfunc (dec *hclDecoder) Init(reader io.Reader) error {\n\tdata, err := io.ReadAll(reader)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfile, diags := hclsyntax.ParseConfig(data, \"input.hcl\", hcl.Pos{Line: 1, Column: 1})\n\tif diags != nil && diags.HasErrors() {\n\t\treturn fmt.Errorf(\"hcl parse error: %w\", diags)\n\t}\n\tdec.file = file\n\tdec.fileBytes = data\n\tdec.readAnything = false\n\tdec.documentIndex = 0\n\treturn nil\n}\n\nfunc (dec *hclDecoder) Decode() (*CandidateNode, error) {\n\tif dec.readAnything {\n\t\treturn nil, io.EOF\n\t}\n\tdec.readAnything = true\n\n\tif dec.file == nil {\n\t\treturn nil, fmt.Errorf(\"no hcl file parsed\")\n\t}\n","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/decoder_hcl.go#L100-L136","documentation":"The HCL decoder's Init fed the whole input to hclsyntax.ParseConfig and the hashicorp/hcl parser returned diagnostics containing at least one error, meaning the input is not syntactically valid HCL. The %w wraps hcl's own diagnostics, which carry line/column detail of the first syntax fault.","triggerScenarios":"Thrown at pkg/yqlib/decoder_hcl.go:118 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the HCL syntax error reported in the wrapped diagnostics (check line/column)","Ensure the input file is actually HCL and not JSON/YAML in disguise","Pass the correct format flag (e.g. --from hcl) if yq auto-detected the wrong format","Validate the file with a dedicated HCL linter before piping it to yq"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8b5af0694bb82b41d4ae180fac9972029066f90a","analyzedAt":"2026-09-05T10:57:22.766Z","contentChangedAt":"2026-09-05T10:57:22.766Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}