Bug 41185 - internal server error on all searches with REST API
Summary: internal server error on all searches with REST API
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: 25.05
Hardware: All Linux
: P5 - low major
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-05 09:01 UTC by Pablo
Modified: 2025-11-05 09:01 UTC (History)
1 user (show)

See Also:
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 (911 bytes, text/plain)
2025-11-05 09:01 UTC, Pablo
Details

Note You need to log in before you can comment on or make changes to this bug.
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.