{"record":{"id":"38ab5e43de62968e","repo":"getsops/sops","slug":"invalid-s-key-configuration-expected-string-s","errorCode":null,"errorMessage":"invalid %s key configuration: expected string, []string, or nil, got %T","messagePattern":"invalid (.+?) key configuration: expected string, \\[\\]string, or nil, got %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":258,"sourceCode":"\t\t\tif trimmed != \"\" { // Skip empty strings (fixes trailing comma issue)\n\t\t\t\tresult = append(result, trimmed)\n\t\t\t}\n\t\t}\n\t\treturn result, nil\n\tcase []interface{}:\n\t\tresult := make([]string, len(v))\n\t\tfor i, item := range v {\n\t\t\tif str, ok := item.(string); ok {\n\t\t\t\tresult[i] = str\n\t\t\t} else {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid %s key configuration: expected string in list, got %T\", fieldName, item)\n\t\t\t}\n\t\t}\n\t\treturn result, nil\n\tcase []string:\n\t\treturn v, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid %s key configuration: expected string, []string, or nil, got %T\", fieldName, field)\n\t}\n}\n\nfunc NewStoresConfig() *StoresConfig {\n\tstoresConfig := &StoresConfig{}\n\tstoresConfig.JSON.Indent = -1\n\tstoresConfig.JSONBinary.Indent = -1\n\treturn storesConfig\n}\n\n// Load loads a sops config file into a temporary struct\nfunc (f *configFile) load(bytes []byte) error {\n\terr := yaml.Unmarshal(bytes, f)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Could not unmarshal config file: %s\", err)\n\t}\n\treturn nil\n}","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/config/config.go#L240-L276","documentation":"parseKeyField's default branch: the field's overall value is neither a string, a []string, nor nil (e.g. a single map or nested list), so key parsing cannot proceed. Unlike error 66 (bad element inside a list), this fires on the whole field having an unsupported type.","triggerScenarios":"Config like `age: {key1: val}` (a map where a string or list is expected), or a nested list `[[a, b]]` passed to GetAgeKeys/GetPGPKeys/GetKMSKeys etc.","commonSituations":"Confusing per-key creation-rule syntax with key-group syntax in .sops.yaml, pasting structured key objects into fields that sops expects as plain strings, wrong YAML indentation creating a mapping instead of a list of strings.","solutions":["Set the field to either a single string or a list of strings in .sops.yaml","For multiple key groups, use the key_groups structure instead of nesting lists on the key field","Validate the YAML structure with `sops` dry-run or a schema check after editing"],"exampleFix":"# before\nage:\n  key1: age1abc...   # map not accepted\n# after\nage:\n  - \"age1abc...\"\n  - \"age1def...\"","handlingStrategy":"validation","validationCode":"// field must be string, []string, or nil\nfunc keyFieldOk(v interface{}) bool {\n\tswitch v.(type) {\n\tcase string, []string, []interface{}, nil:\n\t\t// []interface{} still needs element checks (see error 66)\n\t\treturn true\n\t}\n\treturn false\n}","typeGuard":"func isScalarOrStringList(v interface{}) bool {\n\tif v == nil { return true }\n\tif s, ok := v.(string); ok { return s != \"\" }\n\tif l, ok := v.([]interface{}); ok { return len(l) > 0 }\n\treturn false\n}","tryCatchPattern":"keys, err := cfg.GetPGPKeys(i)\nif err != nil && strings.Contains(err.Error(), \"expected string, []string, or nil\") {\n\treturn fmt.Errorf(\".sops.yaml field must be a string or list of strings, not a map: %w\", err)\n}","preventionTips":["Never put a mapping (key: value) under age/pgp/kms lists in creation_rules","Use sops' key_groups structure for multi-group setups instead of nesting lists","Validate .sops.yaml structure with sops or a YAML schema tool after edits","Keep one key entry per list line as a quoted string"],"tags":["configuration","yaml","type-mismatch","sops"],"backgroundTag":"config-type-mismatch","analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}