{"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/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/cliconfig/cliconfig.go#L149-L185","documentation":"Emitted by `loadConfigFile` (cliconfig.go:167) when `hcl.Parse` fails on the contents of a CLI config file. This is an HCL syntax error in the file itself — the bytes were read successfully but do not form a valid HCL top-level structure. The `%s` values are the path and the HCL parser error.","triggerScenarios":"A `.terraformrc` (or `*.tfrc`) file containing malformed HCL: unclosed blocks, bad attribute syntax, stray characters, mismatched quotes/braces.","commonSituations":"Hand-editing the CLI config and leaving a typo; pasting JSON into an HCL file; truncation from a crashed editor; mixing tabs/spaces incorrectly in block headers.","solutions":["Open the file named in the error and fix the HCL syntax at the line/column the parser reports.","Validate with an HCL linter or by running `terraform init` again to surface the precise location.","Compare against a known-good `.terraformrc` block structure (e.g. `credentials \"app.terraform.io\" { token = \"...\" }`).","If unsure, comment out suspect blocks with `#` and re-run."],"exampleFix":"# before (~/.terraformrc)\ncredentials \"app.terraform.io\" {\n  token = \"atlasv1...\"\n# missing closing brace\n\n# after\ncredentials \"app.terraform.io\" {\n  token = \"atlasv1...\"\n}","handlingStrategy":"try-catch","validationCode":"// Validate HCL syntax with the same parser the loader uses (best-effort).\nimport \"github.com/hashicorp/hcl\"\n\nfunc configParses(path string) error {\n    b, err := os.ReadFile(path)\n    if err != nil {\n        return err\n    }\n    _, err = hcl.Parse(string(b))\n    return err\n}","typeGuard":null,"tryCatchPattern":"// cfg, diags := cliconfig.LoadConfig()\nfor _, d := range diags {\n    if strings.HasPrefix(d.Description().Summary, \"Error parsing\") {\n        // Point user to the line/col reported by HCL.\n    }\n}","preventionTips":["Lint `.terraformrc` edits before committing.","Keep block/brace structure balanced; close every `{`.","Avoid pasting JSON into an HCL file."],"tags":["terraform","cli-config","hcl","parse-error","syntax"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}