[Bug 39408] New: Cannot add patron via API if AutoEmailNewUser and WELCOME content blank
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Bug ID: 39408 Summary: Cannot add patron via API if AutoEmailNewUser and WELCOME content blank Change sponsored?: --- Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Patrons Assignee: koha-bugs@lists.koha-community.org Reporter: nick@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle.m.hall@gmail.com Some libraries use Template Toolkit logic to avoid sending emails. In the case of the welcome notice they may only want to send for patrons fully added, not self registered. In the case of Aspen, we currently use the patrons API for self registration as there is not a self registration API. If you add logic like: [% USE Koha %] [% IF borrower.categorycode != 'SELFREG' %] Hello [% borrower.title %] [% borrower.firstname %] [% borrower.surname %].<br> <br> Thank you for joining [% IF Koha.Preference('LibraryName') %][% Koha.Preference('LibraryName') %][% ELSE %]the library[% END %]<br> <br> You can search for all our materials in our <a href='[% Koha.Preference('OPACBaseURL') %]'>catalog</a>.<br> <br> Your library card number is [% borrower.cardnumber %]<br> <br> If you have any problems or questions regarding your account, please contact the library. [% END %] Then add a patron via the API in the self reg class: {"surname":"PATRON","firstname":"PROBLEM","library_id":"CPL","category_id":"SELFREG","email":"eample@example.org"} You get an error response: "Given does not exist" -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Nick Clemens (kidclamp) <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 --- Comment #1 from Nick Clemens (kidclamp) <nick@bywatersolutions.com> --- Created attachment 179613 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=179613&action=edit Bug 39408: Handle BadParameter exception better Currently we assume BadParameter has been thrown with a parameter that is a valid patron field. It may only include a message, or it may have come from outside the patron object, we should handle all cases. To test: 1 - Wrap "WELCOME" notice content in conditional: [% IF borrower.categorycode != 'SELFREG' %] ... [% END %] 2 - Enable preference AutoEmailNewUser 3 - Attempt to self register a patron via API with body: {"surname":"PATRON","firstname":"PROBLEM","library_id":"CPL","category_id":"SELFREG","email":"eample@example.org"} 4 - Response error: "Given does not exist" 5 - Apply this patch, restart all 6 - Repeat 3 7 - Response error: "Exception 'Koha::Exceptions::BadParameter' thrown 'Parameter message_id cannot be empty if passed.'\n" 8 - It's uglier, but actually helpful -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 --- Comment #2 from Nick Clemens (kidclamp) <nick@bywatersolutions.com> --- Created attachment 179614 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=179614&action=edit Bug 39408: Don't attempt to send a message if one is not generated The routine to create the message can return nothing if there is no content, we should handle this case and not attempt to send. To test: 1 - Test plan from last patch 2 - Apply this patch 3 - POST to patron API again 4 - Success! -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Nick Clemens (kidclamp) <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |nick@bywatersolutions.com |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 claire.hernandez@biblibre.com <claire.hernandez@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |claire.hernandez@biblibre.c | |om -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 claire.hernandez@biblibre.com <claire.hernandez@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #179613|0 |1 is obsolete| | --- Comment #3 from claire.hernandez@biblibre.com <claire.hernandez@biblibre.com> --- Created attachment 180255 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180255&action=edit Bug 39408: Handle BadParameter exception better Currently we assume BadParameter has been thrown with a parameter that is a valid patron field. It may only include a message, or it may have come from outside the patron object, we should handle all cases. To test: 1 - Wrap "WELCOME" notice content in conditional: [% IF borrower.categorycode != 'SELFREG' %] ... [% END %] 2 - Enable preference AutoEmailNewUser 3 - Attempt to self register a patron via API with body: {"surname":"PATRON","firstname":"PROBLEM","library_id":"CPL","category_id":"SELFREG","email":"eample@example.org"} 4 - Response error: "Given does not exist" 5 - Apply this patch, restart all 6 - Repeat 3 7 - Response error: "Exception 'Koha::Exceptions::BadParameter' thrown 'Parameter message_id cannot be empty if passed.'\n" 8 - It's uglier, but actually helpful Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 claire.hernandez@biblibre.com <claire.hernandez@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #179614|0 |1 is obsolete| | --- Comment #4 from claire.hernandez@biblibre.com <claire.hernandez@biblibre.com> --- Created attachment 180256 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180256&action=edit Bug 39408: Don't attempt to send a message if one is not generated The routine to create the message can return nothing if there is no content, we should handle this case and not attempt to send. To test: 1 - Test plan from last patch 2 - Apply this patch 3 - POST to patron API again 4 - Success! Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 claire.hernandez@biblibre.com <claire.hernandez@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180255|0 |1 is obsolete| | --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 182165 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=182165&action=edit Bug 39408: Handle BadParameter exception better Currently we assume BadParameter has been thrown with a parameter that is a valid patron field. It may only include a message, or it may have come from outside the patron object, we should handle all cases. To test: 1 - Wrap "WELCOME" notice content in conditional: [% IF borrower.categorycode != 'SELFREG' %] ... [% END %] 2 - Enable preference AutoEmailNewUser 3 - Attempt to self register a patron via API with body: {"surname":"PATRON","firstname":"PROBLEM","library_id":"CPL","category_id":"SELFREG","email":"eample@example.org"} 4 - Response error: "Given does not exist" 5 - Apply this patch, restart all 6 - Repeat 3 7 - Response error: "Exception 'Koha::Exceptions::BadParameter' thrown 'Parameter message_id cannot be empty if passed.'\n" 8 - It's uglier, but actually helpful Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180256|0 |1 is obsolete| | --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 182166 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=182166&action=edit Bug 39408: Don't attempt to send a message if one is not generated The routine to create the message can return nothing if there is no content, we should handle this case and not attempt to send. To test: 1 - Test plan from last patch 2 - Apply this patch 3 - POST to patron API again 4 - Success! Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 --- Comment #7 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 182167 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=182167&action=edit Bug 39408: (QA follow-up) Add unit tests Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |martin.renvoize@openfifth.c |y.org |o.uk CC| |martin.renvoize@openfifth.c | |o.uk Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Failed QA --- Comment #8 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- I applied the patches and ran yarn build. But: FAIL Koha/REST/V1/Patrons.pm FAIL tidiness File is not tidy, please run `perl misc/devel/tidy.pl Koha/REST/V1/Patrons.pm` FAIL t/db_dependent/api/v1/patrons.t FAIL critic # Subroutines::ProhibitExplicitReturnUndef: Got 1 violation(s). Please also double check the tests, I had some trouble there that only went away after a reset_all. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #182165|0 |1 is obsolete| | --- Comment #9 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 187798 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=187798&action=edit Bug 39408: Handle BadParameter exception better Currently we assume BadParameter has been thrown with a parameter that is a valid patron field. It may only include a message, or it may have come from outside the patron object, we should handle all cases. To test: 1 - Wrap "WELCOME" notice content in conditional: [% IF borrower.categorycode != 'SELFREG' %] ... [% END %] 2 - Enable preference AutoEmailNewUser 3 - Attempt to self register a patron via API with body: {"surname":"PATRON","firstname":"PROBLEM","library_id":"CPL","category_id":"SELFREG","email":"eample@example.org"} 4 - Response error: "Given does not exist" 5 - Apply this patch, restart all 6 - Repeat 3 7 - Response error: "Exception 'Koha::Exceptions::BadParameter' thrown 'Parameter message_id cannot be empty if passed.'\n" 8 - It's uglier, but actually helpful Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #182166|0 |1 is obsolete| | --- Comment #10 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 187799 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=187799&action=edit Bug 39408: Don't attempt to send a message if one is not generated The routine to create the message can return nothing if there is no content, we should handle this case and not attempt to send. To test: 1 - Test plan from last patch 2 - Apply this patch 3 - POST to patron API again 4 - Success! Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #182167|0 |1 is obsolete| | --- Comment #11 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 187800 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=187800&action=edit Bug 39408: (QA follow-up) Add unit tests Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Failed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #187798|0 |1 is obsolete| | --- Comment #12 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 187827 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=187827&action=edit Bug 39408: Handle BadParameter exception better Currently we assume BadParameter has been thrown with a parameter that is a valid patron field. It may only include a message, or it may have come from outside the patron object, we should handle all cases. To test: 1 - Wrap "WELCOME" notice content in conditional: [% IF borrower.categorycode != 'SELFREG' %] ... [% END %] 2 - Enable preference AutoEmailNewUser 3 - Attempt to self register a patron via API with body: {"surname":"PATRON","firstname":"PROBLEM","library_id":"CPL","category_id":"SELFREG","email":"eample@example.org"} 4 - Response error: "Given does not exist" 5 - Apply this patch, restart all 6 - Repeat 3 7 - Response error: "Exception 'Koha::Exceptions::BadParameter' thrown 'Parameter message_id cannot be empty if passed.'\n" 8 - It's uglier, but actually helpful Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #187799|0 |1 is obsolete| | --- Comment #13 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 187828 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=187828&action=edit Bug 39408: Don't attempt to send a message if one is not generated The routine to create the message can return nothing if there is no content, we should handle this case and not attempt to send. To test: 1 - Test plan from last patch 2 - Apply this patch 3 - POST to patron API again 4 - Success! Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #187800|0 |1 is obsolete| | --- Comment #14 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 187829 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=187829&action=edit Bug 39408: (QA follow-up) Add unit tests Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com Keywords| |release-notes-needed -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |25.11.00 released in| | Status|Passed QA |Pushed to main -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 --- Comment #15 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Nice work everyone! Pushed to main for 25.11 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|25.11.00 |25.11.00,25.05.05 released in| | Status|Pushed to main |Pushed to stable -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 --- Comment #16 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Nice work everyone! Pushed to 25.05.x -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|25.11.00,25.05.05 |25.11.00,25.05.05,24.1.11 released in| | CC| |fridolin.somers@biblibre.co | |m Status|Pushed to stable |Pushed to oldstable --- Comment #17 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to 24.11.x for 24.11.11 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Marion Durand <marion.durand@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marion.durand@biblibre.com Version(s)|25.11.00,25.05.05,24.1.11 |25.11.00,25.05.05,24.11.11 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39408 Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to oldstable |Needs documenting --- Comment #18 from Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz> --- Not backporting to 22.11.x as it wasn't backported to 24.05.x -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org