Bug 41185

Summary: internal server error on all searches with REST API
Product: Koha Reporter: Pablo <pavel>
Component: REST APIAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: tomascohen
Version: 25.05   
Hardware: All   
OS: Linux   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: patch

Description Pablo 2025-11-05 09:01:37 UTC
Created attachment 189070 [details]
patch

My environment:
Ubuntu Server 24.04 with latest updates
Koha 25.05 from packages
Basic authentication for REST API is enabled.

I run examples from official documentation
https://api.koha-community.org/#section/Filtering-responses

curl -u username:password --request GET "http://hostname/api/v1/patrons/" --data-raw '{ "surname": "Acevedo", "firstname": "Henry" }'

curl -u username:password --request GET "http://hostname/api/v1/patrons/" --data-raw '{ "surname": { "-like": "Ace%" }'

curl -u username:password --request GET "http://hostname/api/v1/patrons/" --data-raw '{ "surname": [ "Acevedo", "Bernardo" ] }'

curl -u username:password --request GET 'http://hostname/api/v1/patrons/' --header 'x-koha-embed: extended_attributes' --data-raw '{ "extended_attributes.code": "internet", "extended_attributes.attribute": "1" }'

They all return this:
{"error":"Something went wrong, check Koha logs for details.","error_code":"internal_server_error"}

Error log:
[ERROR] GET /api/v1/patrons/: unhandled exception (DBIx::Class::Exception)<<DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column '{ "extended_attributes.code": "internet", "extended_attributes.attribute": "1" }' in 'WHERE' at /usr/share/koha/lib/Koha/REST/Plugin/Objects.pm line 284>>

I turn on MariaDB query log and see what causes the error:
SELECT COUNT( * ) FROM `borrowers` `me` WHERE ( ( ( `firstname` = 'Henry' AND `surname` = 'Acevedo' ) AND `{ "surname": "Acevedo", "firstname": "Henry" }` LIKE '%%' ) )

I have developed a patch but this may require further investigation from Koha developers why this is occurring in the first place.