{"record":{"id":"93ec7cfb164bed72","repo":"hashicorp/terraform","slug":"error-parsing-s-s","errorCode":null,"errorMessage":"Error parsing %s: %s","messagePattern":"Error parsing (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/cliconfig/cliconfig.go","lineNumber":167,"sourceCode":"\n// loadConfigFile loads the CLI configuration from \".terraformrc\" files.\nfunc loadConfigFile(path string) (*Config, tfdiags.Diagnostics) {\n\tvar diags tfdiags.Diagnostics\n\tresult := &Config{}\n\n\tlog.Printf(\"Loading CLI configuration from %s\", path)\n\n\t// Read the HCL file and prepare for parsing\n\td, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Error reading %s: %s\", path, err))\n\t\treturn result, diags\n\t}\n\n\t// Parse it\n\tobj, err := hcl.Parse(string(d))\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Error parsing %s: %s\", path, err))\n\t\treturn result, diags\n\t}\n\n\t// Build up the result\n\tif err := hcl.DecodeObject(&result, obj); err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Error parsing %s: %s\", path, err))\n\t\treturn result, diags\n\t}\n\n\t// Deal with the provider_installation block, which is not handled using\n\t// DecodeObject because its structure is not compatible with the\n\t// limitations of that function.\n\tproviderInstBlocks, moreDiags := decodeProviderInstallationFromConfig(obj)\n\tdiags = diags.Append(moreDiags)\n\tresult.ProviderInstallation = providerInstBlocks\n\n\t// Replace all env vars\n\tfor k, v := range result.Providers {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/cliconfig/cliconfig.go#L149-L185","documentation":"Thrown when hcl.Parse fails to parse the CLI configuration file content. This is an HCL syntax error in the .terraformrc file: the file was read successfully but contains invalid HCL syntax that the parser cannot accept.","triggerScenarios":"hcl.Parse(string(d)) returns an error after the file bytes are read. Occurs when the .terraformrc file contains malformed HCL: unclosed blocks, invalid key-value syntax, missing quotes around strings, or stray characters.","commonSituations":"Hand-editing .terraformrc with syntax errors (unclosed braces, missing quotes); mixing JSON syntax into a .tfrc file (use .tfrc.json for JSON); copy-paste introducing invisible characters; outdated config format from very old Terraform versions.","solutions":["Review the .terraformrc file for HCL syntax errors, paying attention to brace matching and quoting","Validate the file with an HCL-aware linter or terraform's own error output which pinpoints the line","Use JSON format (.tfrc.json) if you prefer JSON syntax and tooling","Compare against the documented .terraformrc format in Terraform CLI docs"],"exampleFix":"// before (invalid HCL — missing closing quote)\ncredentials \"app.terraform.io {\n  token = \"xxx\"\n}\n\n// after\ncredentials \"app.terraform.io\" {\n  token = \"xxx\"\n}","handlingStrategy":"validation","validationCode":"// Validate HCL syntax of the config file before running terraform\nfunc validateHCLConfig(path string) error {\n    src, err := os.ReadFile(path)\n    if err != nil {\n        return err\n    }\n    parser := hclparse.NewParser()\n    _, diags := parser.ParseHCL(src, path)\n    if diags.HasErrors() {\n        return diags\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use an HCL-aware editor with syntax checking for .terraformrc files","Validate config files after manual edits with an HCL parser","Consider .tfrc.json format to leverage JSON tooling for validation","Watch for unclosed braces and unquoted strings when hand-editing"],"tags":["cli-config","hcl","parsing","terraformrc","syntax"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}