{"record":{"id":"31f8765e6668fd13","repo":"Billionmail/BillionMail","slug":"decode-password-failed-w","errorCode":null,"errorMessage":"Decode password failed: %w","messagePattern":"Decode password failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/mail_boxes/mail_boxes.go","lineNumber":385,"sourceCode":"\t\treturn nil, fmt.Errorf(\"Failed to create email: %w\", err)\n\t}\n\n\tif len(emailList) == 0 {\n\t\treturn nil, fmt.Errorf(\"Failed to create any mailbox\")\n\t}\n\n\treturn emailList, nil\n}\n\n// AddImport\nfunc AddImport(ctx context.Context, mailbox *v1.Mailbox) (err error) {\n\n\tif mailbox.PasswordEncode != \"\" {\n\n\t\tif mailbox.Password == \"\" {\n\t\t\tmailbox.Password, err = PasswdDecode(ctx, mailbox.PasswordEncode)\n\t\t\tif err != nil {\n\t\t\t\terr = fmt.Errorf(\"Decode password failed: %w\", err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tmailbox.Password, err = PasswdMD5Crypt(ctx, mailbox.Password)\n\t\t\tif err != nil {\n\t\t\t\terr = fmt.Errorf(\"Generate password md5-crypt failed: %w\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t} else {\n\n\t\tmailbox.PasswordEncode = PasswdEncode(ctx, mailbox.Password)\n\t\tmailbox.Password, err = PasswdMD5Crypt(ctx, mailbox.Password)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"Generate password md5-crypt failed: %w\", err)\n\t\t\treturn\n\t\t}","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/mail_boxes/mail_boxes.go#L367-L403","documentation":"Thrown by AddImport when a mailbox record carries an encrypted PasswordEncode but no plaintext Password, and PasswdDecode fails to decrypt the stored encoded password. The decoded plaintext is then needed for md5-crypt hashing, so the import aborts.","triggerScenarios":"Calling ImportMailbox (via AddImport) with PasswordEncode set, Password empty, and PasswdDecode failing — typically because PasswordEncode was encrypted with a different key than the one configured at import time.","commonSituations":"Migrating mailbox data between deployments with different encryption keys/secrets; corrupted or hand-edited PasswordEncode values; importing records exported from another BillionMail instance.","solutions":["Ensure the encryption key/secret used by PasswdEncode/PasswdDecode matches the one that encrypted the source PasswordEncode value","Re-export the source data from the original environment with matching keys, or reset the password and import plaintext Password instead","Verify the PasswordEncode value is not truncated or corrupted in the import source"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if mailbox.PasswordEncode != \"\" && mailbox.Password == \"\" {\n    // verify decode key matches source environment before importing\n    if _, err := PasswdDecode(ctx, mailbox.PasswordEncode); err != nil {\n        // reset password or re-export with matching key\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the same encryption key across export and import environments","Prefer importing plaintext Password and letting the server encode it","Validate PasswordEncode values round-trip before bulk imports"],"tags":["go","password","decryption","import"],"backgroundTag":"password-decrypt-failed","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}