Bug 42102

Summary: Z39.50 ISBN sometimes fails when right truncation provided
Product: Koha Reporter: David Cook <dcook>
Component: Z39.50 / SRU / OpenSearch ServersAssignee: David Cook <dcook>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: david, m.de.rooy
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Crowdfunding committed: 0
Crowdfunding contact: Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 42102: Try with and without right truncation for ISBN
Bug 42102: Try with and without right truncation for ISBN

Description David Cook 2026-03-16 03:35:48 UTC
I've noticed that the Z39.50 search for ISBN no longer works for the Library of Congress.

It appears that their support for the @attr 5=1 right truncation has changed. If you provide the full ISBN, it will fail. If you provide a partial, it will succeed.

The way to work around this is to try both with and without truncation. (Note that places like the National Library of Medicine in the USA will let you provide @attr 5=1 but it doesn't actually perform the right truncation on your ISBN search.)
Comment 1 David Cook 2026-03-16 03:39:35 UTC
Created attachment 195381 [details] [review]
Bug 42102: Try with and without right truncation for ISBN

This change widens the ISBN search to try with and without right
truncation as different Z39.50 servers appear to handle this
differently. Some will ignore it and others will fail to return
a result if a full ISBN is provided (like with the Library of Congress
currently)

Test plan:
0. Do not apply the patch yet
1. Log into koha-testing-docker
2. Do a ISBN search for 9780879933913 for the Library of Congress
(Note to use the Z39.50 and NOT the SRU)
3. Note that it doesn't return any results

4. Apply the patch and koha-plack --restart kohadev

5. Do a ISBN search for 9780879933913 for the Library of Congress
(Note to use the Z39.50 and NOT the SRU)
6. Note that you get a result
7. Do a ISBN search for 978087993391 for the Library of Congress
8. Note that you get a result with the partial ISBN
Comment 2 David Nind 2026-03-16 06:17:45 UTC
Created attachment 195382 [details] [review]
Bug 42102: Try with and without right truncation for ISBN

This change widens the ISBN search to try with and without right
truncation as different Z39.50 servers appear to handle this
differently. Some will ignore it and others will fail to return
a result if a full ISBN is provided (like with the Library of Congress
currently)

Test plan:
0. Do not apply the patch yet
1. Log into koha-testing-docker
2. Do a ISBN search for 9780879933913 for the Library of Congress
(Note to use the Z39.50 and NOT the SRU)
3. Note that it doesn't return any results

4. Apply the patch and koha-plack --restart kohadev

5. Do a ISBN search for 9780879933913 for the Library of Congress
(Note to use the Z39.50 and NOT the SRU)
6. Note that you get a result
7. Do a ISBN search for 978087993391 for the Library of Congress
8. Note that you get a result with the partial ISBN

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2026-03-16 06:18:48 UTC
Occasionally getting this error after the patch:

- Present request out of range (ref. 13) for LIBRARY OF CONGRESS result 1
Comment 4 David Cook 2026-03-16 22:02:23 UTC
(In reply to David Nind from comment #3)
> Occasionally getting this error after the patch:
> 
> - Present request out of range (ref. 13) for LIBRARY OF CONGRESS result 1

Technically, you'd get that error before the patch too on a successful search. That's an outstanding issue I've found with the Library of Congress Z39.50 MetaProxy implementation. 

I'm waiting to hear back from the Library of Congress networking team. At the moment, I suspect that there's 1+ bad nodes behind their proxy which cause intermittent failures. Very annoying...