{"record":{"id":"a055a52be42a5d6b","repo":"getsops/sops","slug":"error-emitting-binary-store","errorCode":null,"errorMessage":"error emitting binary store","messagePattern":"error emitting binary store","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"stores/json/store.go","lineNumber":73,"sourceCode":"// LoadPlainFile loads a plaintext json file onto a sops.Tree encapsulated\n// within a sops.TreeBranches object\nfunc (store BinaryStore) LoadPlainFile(in []byte) (sops.TreeBranches, error) {\n\treturn sops.TreeBranches{\n\t\tsops.TreeBranch{\n\t\t\tsops.TreeItem{\n\t\t\t\tKey:   \"data\",\n\t\t\t\tValue: string(in),\n\t\t\t},\n\t\t},\n\t}, nil\n}\n\n// EmitEncryptedFile produces an encrypted json file's bytes from its corresponding sops.Tree object\nfunc (store BinaryStore) EmitEncryptedFile(in sops.Tree) ([]byte, error) {\n\treturn store.store.EmitEncryptedFile(in)\n}\n\nvar BinaryStoreEmitPlainError = errors.New(\"error emitting binary store\")\n\n// EmitPlainFile produces plaintext json file's bytes from its corresponding sops.TreeBranches object\nfunc (store BinaryStore) EmitPlainFile(in sops.TreeBranches) ([]byte, error) {\n\tif len(in) != 1 {\n\t\treturn nil, fmt.Errorf(\"%w: there must be exactly one tree branch\", BinaryStoreEmitPlainError)\n\t}\n\t// JSON stores a single object per file\n\tfor _, item := range in[0] {\n\t\tif item.Key == \"data\" {\n\t\t\tif value, ok := item.Value.(string); ok {\n\t\t\t\treturn []byte(value), nil\n\t\t\t} else {\n\t\t\t\treturn nil, fmt.Errorf(\"%w: 'data' key in tree does not have a string value\", BinaryStoreEmitPlainError)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"%w: no binary data found in tree\", BinaryStoreEmitPlainError)\n}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/stores/json/store.go#L55-L91","documentation":"Error \"error emitting binary store\" thrown in getsops/sops.","triggerScenarios":"Thrown at stores/json/store.go:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}