{"record":{"id":"5c929552788c3b2e","repo":"getsops/sops","slug":"failed-to-parse-and-add-to-age-identities-w","errorCode":null,"errorMessage":"failed to parse and add to age identities: %w","messagePattern":"failed to parse and add to age identities: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"age/keysource.go","lineNumber":150,"sourceCode":"// It allows for creating a (local) keyservice.KeyServiceServer which parses\n// identities only once, to then inject them using ApplyToMasterKey() for all\n// requests.\ntype ParsedIdentities []age.Identity\n\n// Import attempts to parse the given identities, to then add them to itself.\n// It returns any parsing error.\n// A single identity argument is allowed to be a multiline string containing\n// multiple identities. Empty lines and lines starting with \"#\" are ignored.\n// It is not thread safe, and parallel importing would better be done by\n// parsing (using age.ParseIdentities) and appending to the slice yourself, in\n// combination with e.g. a sync.Mutex.\nfunc (i *ParsedIdentities) Import(identity ...string) error {\n\t// one identity per line\n\tr := strings.NewReader(strings.Join(identity, \"\\n\"))\n\n\tidentities, err := parseIdentities(r, false)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse and add to age identities: %w\", err)\n\t}\n\t*i = append(*i, identities...)\n\treturn nil\n}\n\n// ApplyToMasterKey configures the ParsedIdentities on the provided key.\nfunc (i ParsedIdentities) ApplyToMasterKey(key *MasterKey) {\n\tkey.parsedIdentities = i\n}\n\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","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/age/keysource.go#L132-L168","documentation":"Error \"failed to parse and add to age identities: %w\" thrown in getsops/sops.","triggerScenarios":"Thrown at age/keysource.go:150 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"}