{"record":{"id":"7d952e89f28c11ab","repo":"getsops/sops","slug":"could-not-unmarshal-input-data-s","errorCode":null,"errorMessage":"Could not unmarshal input data: %s","messagePattern":"Could not unmarshal input data: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"stores/ini/store.go","lineNumber":157,"sourceCode":"\t}\n\tbranches, metadata, err := stores.ExtractMetadata(branches, stores.MetadataOpts{\n\t\tFlatten:        stores.MetadataFlattenBelowTop,\n\t\tEscapeNewlines: true,\n\t})\n\tif err != nil {\n\t\treturn sops.Tree{}, err\n\t}\n\treturn sops.Tree{\n\t\tBranches: branches,\n\t\tMetadata: metadata,\n\t}, nil\n}\n\n// LoadPlainFile loads a plaintext INI file's bytes onto a sops.TreeBranches runtime object\nfunc (store *Store) LoadPlainFile(in []byte) (sops.TreeBranches, error) {\n\tbranches, err := store.treeBranchesFromIni(in)\n\tif err != nil {\n\t\treturn branches, fmt.Errorf(\"Could not unmarshal input data: %s\", err)\n\t}\n\treturn branches, nil\n}\n\n// EmitEncryptedFile returns encrypted INI file bytes corresponding to a sops.Tree\n// runtime object\nfunc (store *Store) EmitEncryptedFile(in sops.Tree) ([]byte, error) {\n\tbranches, err := stores.SerializeMetadata(in, stores.MetadataOpts{\n\t\tFlatten:        stores.MetadataFlattenBelowTop,\n\t\tEscapeNewlines: true,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error marshaling metadata: %s\", err)\n\t}\n\treturn store.EmitPlainFile(branches)\n}\n\n// EmitPlainFile returns the plaintext INI file bytes corresponding to a sops.TreeBranches object","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/stores/ini/store.go#L139-L175","documentation":"LoadPlainFile parses plaintext INI bytes with gopkg.in/ini.v1 (treeBranchesFromIni). When ini.LoadSources returns a parse error — malformed syntax, unterminated sections, bad quoting, or invalid structure — this wrapper reports the input could not be unmarshaled, including the underlying parser message.","triggerScenarios":"Calling LoadPlainFile or LoadEncryptedFile on bytes that are not valid INI: e.g. a line like \"=value\" with an empty key, or \"[[bad\" section syntax, or binary/truncated data.","commonSituations":"Editing an encrypted sops INI file by hand and breaking syntax; passing a YAML or JSON file with the --ini flag; a pipe/CI step that truncated or corrupted the file; wrong file encoding (UTF-16) that the parser cannot read.","solutions":["Read the wrapped ini.v1 error (it includes line numbers) and fix the syntax at that line in the input file","Verify the file is actually INI (sections like [name], key=value lines), not YAML/JSON","Re-encode the file as UTF-8/ASCII and ensure it is not truncated or binary-corrupted","Restore the file from version control or a backup if it was hand-edited badly"],"exampleFix":"// before (broken INI)\n=missingkey\n\n// after\nkey=value","handlingStrategy":"try-catch","validationCode":"func looksLikeIni(data []byte) bool {\n\tfor _, line := range strings.Split(string(data), \"\\n\") {\n\t\tl := strings.TrimSpace(line)\n\t\tif l == \"\" || strings.HasPrefix(l, \";\") || strings.HasPrefix(l, \"#\") || strings.HasPrefix(l, \"[\") {\n\t\t\tcontinue\n\t\t}\n\t\tif !strings.Contains(l, \"=\") {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}","typeGuard":null,"tryCatchPattern":"branches, err := store.LoadPlainFile(data)\nif err != nil {\n\tvar parseErr error\n\tif strings.Contains(err.Error(), \"Could not unmarshal input data\") {\n\t\treturn fmt.Errorf(\"input is not valid INI; check the line noted in: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Confirm file format matches the store you pass it to","Never hand-edit encrypted files; use the sops CLI","Validate syntax in CI before encrypt/decrypt","Ensure files are UTF-8 and not truncated"],"tags":["go","sops","ini","parsing"],"backgroundTag":"ini-parse-error","analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}