hashicorp/terraform · error
error loading config with snapshot
Error message
error loading config with snapshot: %w
What it means
parseRunVariables calls op.ConfigLoader.LoadRootModule(op.ConfigDir); if that returns diagnostics with errors (syntax errors, malformed HCL, unreadable files), the first error diagnostic is wrapped and surfaced. This runs before uploading the config snapshot, so it gates on local config validity.
Solutions
- Run `terraform validate` locally to surface the exact HCL error before retrying.
- Open the first diagnostic (configDiags.Errs()[0] is wrapped)—its message names the file and line.
- Fix file permissions if the runner cannot read a .tf/.tfvars file.
- Verify module source paths resolve in the runner's working directory.
Example fix
// before (variables.tf)
variable "instance_count" {
type = number
default = "3" // type mismatch
}
// after
variable "instance_count" {
type = number
default = 3
} Defensive patterns
Strategy: validation
Validate before calling
// run validate before pushing the snapshot
diags := root.LoadConfig(op.ConfigDir)
if diags.HasErrors() {
return diags.Errs()[0]
} Prevention
- Run `terraform validate` and `terraform fmt -check` in CI before any cloud run.
- Keep HCL syntax tight; lint .tfvars too.
- Ensure the runner has read permission on all .tf/.tfvars files.
- Validate module paths resolve in the runner's working directory.
When it happens
Trigger: LoadRootModule returns configDiags.HasErrors(): HCL syntax error in a .tf/.tfvars file; missing required provider block; circular module references; unreadable file due to permissions; invalid variable definitions.
Common situations: Developer committed a typo in a .tf file; a referenced module path is wrong; .tfvars has a syntax error; file mode/ownership blocks the runner from reading a .tf file.
Related errors
- backend does not support key/value tags. Try using key-only…
- Error asking
- error creating workspace
- error finding remote workspace
- error loading state
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/d4b7dd4d1ad54bfa.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cloud/backend_common.go:659
uploaded = true
}
}
}
if !uploaded {
return nil, b.generalError(
"Failed to upload configuration files", errors.New("operation timed out"))
}
log.Printf("[TRACE] backend/cloud: configuration uploaded and ready")
return cv, nil
}
func (b *Cloud) parseRunVariables(op *backendrun.Operation) ([]*tfe.RunVariable, error) {
config, configDiags := op.ConfigLoader.LoadRootModule(op.ConfigDir)
if configDiags.HasErrors() {
return nil, fmt.Errorf("error loading config with snapshot: %w", configDiags.Errs()[0])
}
variables, varDiags := ParseCloudRunVariables(op.Variables, config.Variables)
if varDiags.HasErrors() {
return nil, varDiags.Err()
}
runVariables := make([]*tfe.RunVariable, 0, len(variables))
for name, value := range variables {
runVariables = append(runVariables, &tfe.RunVariable{
Key: name,
Value: value,
})
}
return runVariables, nil
}View on GitHub (pinned to d32a084675)