{"record":{"id":"dc87001058fe2206","repo":"getsops/sops","slug":"sops-only-supports-json-files-with-a-top-level-obj","errorCode":null,"errorMessage":"SOPS only supports JSON files with a top-level object (starting with '{'), not arrays or other types. Got delimiter %s instead. To encrypt this file, wrap it in an object, e.g., {\"data\": [...]","messagePattern":"SOPS only supports JSON files with a top-level object \\(starting with '\\{'\\), not arrays or other types\\. Got delimiter (.+?) instead\\. To encrypt this file, wrap it in an object, e\\.g\\., \\{\"data\": \\[\\.\\.\\.\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"stores/json/store.go","lineNumber":292,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn store.reindentJSON(out)\n}\n\nfunc (store Store) treeBranchFromJSON(in []byte) (sops.TreeBranch, error) {\n\tdec := json.NewDecoder(bytes.NewReader(in))\n\t// Decode numbers as json.Number instead of the default float64, then\n\t// normalize each to int/float64 (see normalizeJSONNumber). The default\n\t// float64 silently loses precision for integers larger than 2^53.\n\tdec.UseNumber()\n\tvalue, err := dec.Token()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif delim, ok := value.(json.Delim); ok {\n\t\tif delim.String() != \"{\" {\n\t\t\treturn nil, fmt.Errorf(\"SOPS only supports JSON files with a top-level object (starting with '{'), not arrays or other types. Got delimiter %s instead. To encrypt this file, wrap it in an object, e.g., {\\\"data\\\": [...]}\", value)\n\t\t}\n\t} else {\n\t\tv, nerr := normalizeJSONNumber(value)\n\t\tif nerr != nil {\n\t\t\tv = value\n\t\t}\n\t\treturn nil, fmt.Errorf(\"SOPS only supports JSON files with a top-level object (starting with '{'), not other JSON types. Got %#v of type %T instead\", v, v)\n\t}\n\treturn store.treeBranchFromJSONDecoder(dec)\n}\n\nfunc (store Store) reindentJSON(in []byte) ([]byte, error) {\n\tvar out bytes.Buffer\n\tindent := \"\\t\"\n\tif store.config.Indent > -1 {\n\t\tindent = strings.Repeat(\" \", store.config.Indent)\n\t} else if store.config.Indent < -1 {\n\t\treturn nil, errors.New(\"JSON Indentation parameter smaller than -1 is not accepted\")","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/stores/json/store.go#L274-L310","documentation":"Error \"SOPS only supports JSON files with a top-level object (starting with '{'), not arrays or other types. Got delimiter %s instead. To encrypt this file, wrap it in an object, e.g., {\"data\": [...]\" thrown in getsops/sops.","triggerScenarios":"Thrown at stores/json/store.go:292 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"}