Bug 40219 - Welcome Email Sent on Failed Patron Registration via API
Summary: Welcome Email Sent on Failed Patron Registration via API
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Leo Stoyanov
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-23 14:19 UTC by Leo Stoyanov
Modified: 2025-06-23 15:40 UTC (History)
1 user (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40219: Moved Extended Attributes Validation Before Enqueuing Welcome Email (2.27 KB, patch)
2025-06-23 15:40 UTC, Leo Stoyanov
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Stoyanov 2025-06-23 14:19:09 UTC
When registering a new patron via the /api/v1/patrons API endpoint, a welcome email notice is sent even if the endpoint returns a 400 error due to validation failures. This occurs because the welcome email logic executes before extended attribute validation is complete, within the database transaction.
Comment 1 Leo Stoyanov 2025-06-23 15:40:38 UTC
Created attachment 183421 [details] [review]
Bug 40219: Moved Extended Attributes Validation Before Enqueuing Welcome Email

Test Plan:
1. Configure Koha with: AutoEmailNewUser = "Send" and create a mandatory extended attribute that will cause validation to fail; for example, set for the attribute to display in the OPAC, to be editable in the OPAC, and to be mandatory. That means this bug must be tested before Bug 40220, where the validation failure is resolved.
2. Setup your Postman, or any other mock API software, to obtain an OAuth token (/api/v1/oauth/token) and to register a patron (/api/v1/patrons).
3. With the OAuth token, send a POST request to /api/v1/patrons with valid patron data and invalid or missing mandatory extended attribute data.
4. Observe the API response with the 400 error and notice that the welcome email was delviered despite the fact that no patron account was created.
5. Apply the patch and repeat step 3. Notice that the API response still contains the 400 error, but no welcome email was sent.