{"record":{"id":"02d17a235afff1eb","repo":"getsops/sops","slug":"cannot-use-complex-value-in-dotenv-file-offending","errorCode":null,"errorMessage":"cannot use complex value in dotenv file; offending key %s","messagePattern":"cannot use complex value in dotenv file; offending key (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"stores/dotenv/store.go","lineNumber":93,"sourceCode":"// EmitEncryptedFile returns the encrypted file's bytes corresponding to a sops\n// runtime object\nfunc (store *Store) EmitEncryptedFile(in sops.Tree) ([]byte, error) {\n\tbranches, err := stores.SerializeMetadata(in, stores.MetadataOpts{\n\t\tFlatten: stores.MetadataFlattenFull,\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 file's bytes corresponding to a sops\n// runtime object\nfunc (store *Store) EmitPlainFile(in sops.TreeBranches) ([]byte, error) {\n\tbuffer := bytes.Buffer{}\n\tfor _, item := range in[0] {\n\t\tif stores.IsComplexValue(item.Value) {\n\t\t\treturn nil, fmt.Errorf(\"cannot use complex value in dotenv file; offending key %s\", item.Key)\n\t\t}\n\t\tvar line string\n\t\tif comment, ok := item.Key.(sops.Comment); ok {\n\t\t\tline = fmt.Sprintf(\"#%s\\n\", comment.Value)\n\t\t} else {\n\t\t\tvalue, ok := item.Value.(string)\n\t\t\tif !ok {\n\t\t\t\tvalue = stores.ValToString(item.Value)\n\t\t\t} else {\n\t\t\t\tvalue = strings.ReplaceAll(value, \"\\n\", \"\\\\n\")\n\t\t\t}\n\n\t\t\tline = fmt.Sprintf(\"%s=%s\\n\", item.Key, value)\n\t\t}\n\t\tbuffer.WriteString(line)\n\t}\n\treturn buffer.Bytes(), nil\n}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/stores/dotenv/store.go#L75-L111","documentation":"Error \"cannot use complex value in dotenv file; offending key %s\" thrown in getsops/sops.","triggerScenarios":"Thrown at stores/dotenv/store.go:93 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"}