{"record":{"id":"9c7b31c78b733c3e","repo":"getsops/sops","slug":"error-loading-config-s","errorCode":null,"errorMessage":"error loading config: %s","messagePattern":"error loading config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":462,"sourceCode":"\t\t}\n\t\tfor _, k := range vaultKeys {\n\t\t\tkeyGroup = append(keyGroup, k)\n\t\t}\n\t\tgroups = append(groups, keyGroup)\n\t}\n\treturn groups, nil\n}\n\nfunc loadConfigFile(confPath string) (*configFile, error) {\n\tconfBytes, err := os.ReadFile(confPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not read config file: %s\", err)\n\t}\n\tconf := &configFile{}\n\tconf.Stores = *NewStoresConfig()\n\terr = conf.load(confBytes)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error loading config: %s\", err)\n\t}\n\treturn conf, nil\n}\n\nfunc configFromRule(rule *creationRule, kmsEncryptionContext map[string]*string) (*Config, error) {\n\tcryptRuleCount := 0\n\tif rule.UnencryptedSuffix != \"\" {\n\t\tcryptRuleCount++\n\t}\n\tif rule.EncryptedSuffix != \"\" {\n\t\tcryptRuleCount++\n\t}\n\tif rule.UnencryptedRegex != \"\" {\n\t\tcryptRuleCount++\n\t}\n\tif rule.EncryptedRegex != \"\" {\n\t\tcryptRuleCount++\n\t}","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/config/config.go#L444-L480","documentation":"After successfully reading the config file bytes, loadConfigFile calls conf.load to parse them (YAML/TOML/JSON) into the configFile struct. This error wraps any parsing/unmarshaling failure, so the config file exists but is malformed or does not match the expected schema.","triggerScenarios":"conf.load(confBytes) returns an error because the file contains invalid YAML/TOML/JSON syntax, wrong indentation, tabs in YAML, or unexpected field types for known keys.","commonSituations":"Hand-edited .sops.yaml with broken indentation; pasting TOML config into a file inferred as YAML; key typo producing a schema mismatch in strict parsers.","solutions":["Run a YAML/TOML/JSON linter against the config file to find the syntax error (yamllint .sops.yaml)","Check indentation: YAML files must use consistent spaces, never tabs","Validate that top-level keys are creation_rules and destination_rules with correct types (lists of maps)","Restore a known-good config from git history: git diff HEAD -- .sops.yaml"],"exampleFix":"# before (tabs break YAML)\ncreation_rules:\n\t- path_regex: .*\\.yaml\n# after\ncreation_rules:\n  - path_regex: '.*\\.yaml'","handlingStrategy":"validation","validationCode":"var raw map[string]interface{}\nif err := yaml.Unmarshal(confBytes, &raw); err != nil {\n    return fmt.Errorf(\"config file is not valid YAML: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"conf, err := loadConfigFile(confPath)\nif err != nil && strings.HasPrefix(err.Error(), \"error loading config:\") {\n    // point the operator at the file and run yamllint on it\n    return fmt.Errorf(\"fix syntax in %s: %w\", confPath, err)\n}","preventionTips":["Lint .sops.yaml with yamllint or a JSON/TOML parser in CI","Use spaces, never tabs, in YAML configs","Keep a known-good example config in the repo for reference","Validate config changes with a dry-run sops command before merging"],"tags":["config","yaml","parse-error","sops"],"backgroundTag":"config-parse-error","analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}