{"record":{"id":"44018b3c70cccf1a","repo":"getsops/sops","slug":"failed-to-create-writer-for-encrypting-sops-data-k","errorCode":null,"errorMessage":"failed to create writer for encrypting sops data key with age: %w","messagePattern":"failed to create writer for encrypting sops data key with age: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"age/keysource.go","lineNumber":178,"sourceCode":"\n// Encrypt takes a SOPS data key, encrypts it with the Recipient, and stores\n// the result in the EncryptedKey field.\nfunc (key *MasterKey) Encrypt(dataKey []byte) error {\n\tif key.parsedRecipient == nil {\n\t\tparsedRecipient, err := parseRecipient(key.Recipient)\n\t\tif err != nil {\n\t\t\tlog.WithField(\"recipient\", key.parsedRecipient).Info(\"Encryption failed\")\n\t\t\treturn err\n\t\t}\n\t\tkey.parsedRecipient = parsedRecipient\n\t}\n\n\tvar buffer bytes.Buffer\n\taw := armor.NewWriter(&buffer)\n\tw, err := age.Encrypt(aw, key.parsedRecipient)\n\tif err != nil {\n\t\tlog.WithField(\"recipient\", key.parsedRecipient).Info(\"Encryption failed\")\n\t\treturn fmt.Errorf(\"failed to create writer for encrypting sops data key with age: %w\", err)\n\t}\n\tif _, err := w.Write(dataKey); err != nil {\n\t\tlog.WithField(\"recipient\", key.parsedRecipient).Info(\"Encryption failed\")\n\t\treturn fmt.Errorf(\"failed to encrypt sops data key with age: %w\", err)\n\t}\n\tif err := w.Close(); err != nil {\n\t\tlog.WithField(\"recipient\", key.parsedRecipient).Info(\"Encryption failed\")\n\t\treturn fmt.Errorf(\"failed to close writer for encrypting sops data key with age: %w\", err)\n\t}\n\tif err := aw.Close(); err != nil {\n\t\tlog.WithField(\"recipient\", key.parsedRecipient).Info(\"Encryption failed\")\n\t\treturn fmt.Errorf(\"failed to close armored writer: %w\", err)\n\t}\n\n\tkey.SetEncryptedDataKey(buffer.Bytes())\n\tlog.WithField(\"recipient\", key.parsedRecipient).Info(\"Encryption succeeded\")\n\treturn nil\n}","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/age/keysource.go#L160-L196","documentation":"Error \"failed to create writer for encrypting sops data key with age: %w\" thrown in getsops/sops.","triggerScenarios":"Thrown at age/keysource.go:178 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"}