Bugzilla – Attachment 182165 Details for
Bug 39408
Cannot add patron via API if AutoEmailNewUser and WELCOME content blank
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39408: Handle BadParameter exception better
Bug-39408-Handle-BadParameter-exception-better.patch (text/plain), 2.22 KB, created by
Martin Renvoize (ashimema)
on 2025-05-09 12:27:22 UTC
(
hide
)
Description:
Bug 39408: Handle BadParameter exception better
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-05-09 12:27:22 UTC
Size:
2.22 KB
patch
obsolete
>From b275dae5c0ea191b8cce4b7842014e9bd7c9934f Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 21 Mar 2025 13:53:11 +0000 >Subject: [PATCH] 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> >--- > Koha/REST/V1/Patrons.pm | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > >diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm >index 9d25ef7cba5..3ed1081d898 100644 >--- a/Koha/REST/V1/Patrons.pm >+++ b/Koha/REST/V1/Patrons.pm >@@ -183,9 +183,12 @@ sub add { > openapi => { error => "Given " . $to_api_mapping->{ $_->broken_fk } . " does not exist" } > ); > } elsif ( $_->isa('Koha::Exceptions::BadParameter') ) { >+ my $parameter = $to_api_mapping->{ $_->parameter } || $_->parameter; >+ my $error = >+ $parameter ? "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" : $_->full_message; > return $c->render( > status => 400, >- openapi => { error => "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" } >+ openapi => { error => $error } > ); > } elsif ( $_->isa('Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute') ) { > return $c->render( >-- >2.49.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39408
:
179613
|
179614
|
180255
|
180256
| 182165 |
182166
|
182167