{"record":{"id":"682aff9592f64671","repo":"Billionmail/BillionMail","slug":"failed-to-remove-exception-recipient-w","errorCode":null,"errorMessage":"Failed to remove exception recipient: %w","messagePattern":"Failed to remove exception recipient: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/abnormal_recipient/abnormal_recipient.go","lineNumber":75,"sourceCode":"\t\t\t\"create_time\": now,\n\t\t}).\n\t\tInsertIgnore()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to add exception recipient: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc Delete(ctx context.Context, id int) error {\n\n\t_, err := g.DB().Model(\"abnormal_recipient\").\n\t\tWhere(\"id\", id).\n\t\tDelete()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to remove exception recipient: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc GetAbnormalRecipient(ctx context.Context, id int) (*entity.AbnormalRecipient, error) {\n\tvar recipient entity.AbnormalRecipient\n\terr := g.DB().Model(\"abnormal_recipient\").Where(\"id\", id).Scan(&recipient)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to get exception recipient: %w\", err)\n\t}\n\treturn &recipient, nil\n}\n\nfunc BatchUpsertAbnormalRecipients(ctx context.Context, recipients []string, addType int, description string) error {\n\tnow := time.Now().Unix()\n\n\tif len(recipients) == 0 {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/abnormal_recipient/abnormal_recipient.go#L57-L93","documentation":"Delete removes one row from abnormal_recipient by id via g.DB().Model(...).Delete(). Any SQL failure (bad connection, table missing, permission denied) is wrapped as this error and returned to DeleteAbnormalRecipient.","triggerScenarios":"Calling Delete(ctx, id) with the database down, abnormal_recipient absent, or the DB role lacking DELETE privilege.","commonSituations":"Deleting a stale recipient after the DB was migrated/recreated; connection pool exhaustion after idle timeout; read-only replicas receiving writes.","solutions":["Confirm DB connectivity and that the abnormal_recipient table exists.","Check DELETE grants for the app's DB role.","Inspect the wrapped driver error for the precise SQL failure.","Note: a nonexistent id is not an error here — only SQL failures are."],"exampleFix":"// before\nabnormal_recipient.Delete(ctx, id)\n// after\nif err := abnormal_recipient.Delete(ctx, id); err != nil {\n\tlogger.Error(ctx, \"delete abnormal recipient\", \"id\", id, \"err\", err)\n\treturn err\n}","handlingStrategy":"try-catch","validationCode":"// before calling Delete\nif id <= 0 { return errors.New(\"invalid id\") }","typeGuard":null,"tryCatchPattern":"if err := abnormal_recipient.Delete(ctx, id); err != nil {\n\tlogger.Error(ctx, \"delete failed\", \"id\", id, \"err\", err)\n\treturn fmt.Errorf(\"delete recipient %d: %w\", id, err)\n}","preventionTips":["Validate id > 0 before calling","Check DB DELETE grants for the app role","Watch for connection-pool exhaustion in metrics"],"tags":["database","goframe","delete-failure"],"backgroundTag":"database-delete-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"}