Bug 41794

Summary: Error 500 in http://192.168.1.12:8080/cgi-bin/koha/cataloguing/z3950_search.pl
Product: Koha Reporter: Manos PETRIDIS <egpetridis>
Component: CatalogingAssignee: Bugs List <koha-bugs>
Status: REOPENED --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: dcook, m.de.rooy
Version: 25.11   
Hardware: All   
OS: All   
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: intranet-access.log
intranet-error.log
z3950-error.log
results example 1
results example 2
results example 3
z39.50 search result page, showing 500$a info
Intranet access log
intranet error log
Apache error log
OPAC access log

Description Manos PETRIDIS 2026-02-07 17:43:54 UTC
Created attachment 192677 [details]
intranet-access.log

When searching z39.50 targets simultaneously, sometimes we get an 500 error. No further information on what target's response makes koha raise the error. What could be done to 
* make koha report on the targets sucessfully queried,
* make koha not stumble when encountering erroneous replies from z39.50 targets
* make koha note in the logs the target raising the error. 
The following logs are not redacted, the search was repeated after clearing logs and doing an init 6, so that logs would be more readable.
Comment 1 Manos PETRIDIS 2026-02-07 17:44:55 UTC
Created attachment 192678 [details]
intranet-error.log
Comment 2 Manos PETRIDIS 2026-02-07 17:46:49 UTC
Created attachment 192679 [details]
z3950-error.log

File z3950.log is empty therefore cannot be uploaded here.
Comment 3 Katrin Fischer 2026-02-09 13:29:14 UTC
Please check your configuration for the AdditionalFieldsInZ3950Result system preference. It says there is some invalid code in there.
Comment 4 Katrin Fischer 2026-02-09 13:29:43 UTC
invalid expression in AdditionalFieldsInZ3950Result(Auth)Search
Comment 5 Manos PETRIDIS 2026-02-09 15:55:43 UTC
Created attachment 192810 [details]
results example 1
Comment 6 Manos PETRIDIS 2026-02-09 15:56:29 UTC
Created attachment 192811 [details]
results example 2
Comment 7 Manos PETRIDIS 2026-02-09 15:57:24 UTC
Created attachment 192812 [details]
results example 3
Comment 8 Manos PETRIDIS 2026-02-09 16:08:48 UTC
Thank you for the time and attention! I failed to notice the pointer to the error in the logs. I beg to differ however, the issue is neither invalid nor resolved.  

AdditionalFieldsInZ3950Result value is "022$a, 040$a, 082$a2, 092$a2, 245$abc, 247$a, 260$abc, 440$a, 500a, 600$a, 650$avxyz2, 651$avxyz2". Which part is erroneous, and why? Are any of these fields noted in a do-not-use list somewhere in koha documentation?

If indeed the value above was an "invalid expression", then we wouldn't get any results. Please note attached examples of result pages. 

It seems that some servers/targets include garbage/erroneous data in their replies, and koha is unable to report the fact, recover and proceed to the next server in the list.

In order to make things clearer, one may 
* make koha report on the targets sucessfully queried,
* make koha not stumble when encountering erroneous replies from z39.50 targets
* make koha note in the logs the target raising the error. 

You may recreate the error by querying LOC for title "koha" or keyword "koha", using the AdditionalFieldsInZ3950Result value above.
Comment 9 Katrin Fischer 2026-02-10 11:59:39 UTC
(In reply to Manos PETRIDIS from comment #8)
> Thank you for the time and attention! I failed to notice the pointer to the
> error in the logs. I beg to differ however, the issue is neither invalid nor
> resolved.  
> 
> AdditionalFieldsInZ3950Result value is "022$a, 040$a, 082$a2, 092$a2,
> 245$abc, 247$a, 260$abc, 440$a, 500a, 600$a, 650$avxyz2, 651$avxyz2". Which
> part is erroneous, and why? Are any of these fields noted in a do-not-use
> list somewhere in koha documentation?

You are missing the $ for 500a.

The error tells you that too:
Breeding: invalid expression in AdditionalFieldsInZ3950Result(Auth)Search: 500a 

> If indeed the value above was an "invalid expression", then we wouldn't get
> any results. Please note attached examples of result pages. 

Can you please fix that and retry?
Comment 10 Manos PETRIDIS 2026-02-10 21:35:43 UTC
Created attachment 192947 [details]
z39.50 search result page, showing 500$a info

AdditionalFieldsInZ3950ResultSearch value now is "022$a, 040$a, 082$a2, 092$a2, 245$abc, 247$a, 260$abc, 440$a, 500$a, 600$a, 650$avxyz2, 651$avxyz2".
This is reflected in image #4, where we can see that field 500$a is shown in the results, when searching against known "safe" targets.
Comment 11 Manos PETRIDIS 2026-02-10 21:37:50 UTC
Still however, when I search for "koha" on LOC, I get error 500. Same search, having cleared AdditionalFieldsInZ3950ResultSearch still brings up error 500.
Previous attachments updated with the current logs.
Comment 12 Manos PETRIDIS 2026-02-10 21:38:58 UTC
Created attachment 192948 [details]
Intranet access log
Comment 13 Katrin Fischer 2026-02-10 21:39:12 UTC
(In reply to Manos PETRIDIS from comment #11)
> Still however, when I search for "koha" on LOC, I get error 500. Same
> search, having cleared AdditionalFieldsInZ3950ResultSearch still brings up
> error 500.
> Previous attachments updated with the current logs.

LOC recently switched systems, we had some other reports about trouble with search. Not sure if that is something we can solve apart from a nicer error.
Comment 14 Manos PETRIDIS 2026-02-10 21:40:11 UTC
Created attachment 192949 [details]
intranet error log
Comment 15 Manos PETRIDIS 2026-02-10 21:41:27 UTC
Created attachment 192950 [details]
Apache error log
Comment 16 Manos PETRIDIS 2026-02-10 21:42:12 UTC
Created attachment 192951 [details]
OPAC access log
Comment 17 Katrin Fischer 2026-02-10 21:43:04 UTC
U+3BC from the logs is "GREEK SMALL LETTER MU" - could you check if the same error appears with the English GUI to rule out a translation issue?
Comment 18 Manos PETRIDIS 2026-02-10 23:54:39 UTC
Same error appears having selected English (en) interface. 

Tried to modify /usr/share/local/lib/C4/Breeding.pm so that it would write to a log in /tmp just before querying each z39.50 target, but I have still to get an output.
Comment 19 Marcel de Rooy 2026-02-11 13:25:55 UTC
Error 500 in http://192.168.1.12:8080/cgi-bin/koha/cataloguing/z3950_search.pl

192.168 is a private IP range, right?
Comment 20 Manos PETRIDIS 2026-02-11 20:03:46 UTC
Correct, 192.168.0.0 are private networks, the newer logs however were created accessing the server's external address.