Koha Solutions knowledge base: run log of a live check Article https://kohasolutions.com/knowledge-base/koha-items-table-500-error Check scripts/kb/live/koha-items-table-500-error.mjs (SHA-256 63c521787c282f1e732cff2e0ed0d3d76679d4850e8286db849c99bec10cdc8a) Ran 2026-11-05T14:27:44Z (UTC), 28 s Koha 26.05.02 (Koha::version 26.05.02.002, database version 26.0600002) Source https://git.koha-community.org/Koha-community/Koha/src/commit/d3fc229bc5eaea25dfe88f86149386408fe5d32d System Debian GNU/Linux 13 (trixie) Result PASS: all 8 claims held Each claim is something the article says. "seen" is what the check read back when it is not just a yes/no. Changes the check made to the test server were undone afterwards, as its header describes. == Claims == ok item 1 has a holding library to begin with seen: CPL ok the items table's own request answers 500 {"error":"Something went wrong, check Koha logs for details.","error_code":"internal_server_error"} seen: 500 {"error":"Something went wrong, check Koha logs for details.","error_code":"internal_server_error"} ok tail -n 0 -f: the two file headers, then under plack-api-error.log "[date] [ERROR] GET /api/v1/biblios//items: unhandled exception (Mojo::Exception)<>" (one line, two spaces) seen: ==> /var/log/koha/kohadev/plack-api-error.log <== ==> /var/log/koha/kohadev/api-error.log <== ==> /var/log/koha/kohadev/plack-api-error.log <== [2026/11/05 14:27:49] [ERROR] GET /api/v1/biblios/1/items: unhandled exception (Mojo::Exception)<> ok nothing in api-error.log or intranet-error.log for it (the log is plack-api-error.log) ok the same call without home_library/holding_library in the embed answers 200 ok search_for_data_inconsistencies.pl: the "== Not defined items.homebranch and/or items.holdingbranch ==" section names item 1 ("does not have a holding library defined") and ends "=> Edit these items and set valid homebranch and/or holdingbranch", with other sections around it seen: :8: parser error : PCDATA invalid Char value 31 00aD000015937 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ok … "does not have home and holding library defined" is the wording when both are missing (item 2114 on kohadev) ok the SQL (two lines joined by a backslash) → header "itemnumber\tbiblionumber\tbarcode\thomebranch\tholdingbranch" and item 1 with holdingbranch NULL seen: itemnumber biblionumber barcode homebranch holdingbranch 1 1 3999900000001 CPL NULL 2114 1618 PAR-C3 NULL NULL 2115 1618 PAR-C4 PAY NULL == The check that produced this log (scripts/kb/live/koha-items-table-500-error.mjs) == /** * Live check for prisma/ks-kb/24-koha-items-table-500-error.ts (plan203 §A3). * On live Koha: item 1's holdingbranch is set to NULL for the run (put back by the restore) and the staff items API is * called the way the catalogue detail table calls it (catalogue_detail.inc 307 embed list), with a staff session made * by curl. Nothing else changes. The two items the article's sample output shows (2114, 2115 on biblio 1618) were * already on kohadev without branches; this check does not depend on them. ~40 s. */ export const meta = { koha: '26.05.02', passed: '2026-11-05' } const EMBED = '+strings,_status,home_library,holding_library,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk' export default async function run(ctx) { const I = ctx.INSTANCE const L = `/var/log/koha/${I}` const ho = ctx.sqlValue('SELECT holdingbranch FROM items WHERE itemnumber = 1') const bn = ctx.sqlValue('SELECT biblionumber FROM items WHERE itemnumber = 1') ctx.check('item 1 has a holding library to begin with', Boolean(ho) && ho !== 'NULL', ho) ctx.restore('item 1 holdingbranch back', () => ctx.sql(`UPDATE items SET holdingbranch = ${ctx.q(ho)} WHERE itemnumber = 1`)) ctx.sql('UPDATE items SET holdingbranch = NULL WHERE itemnumber = 1') const J = '/tmp/kbv24j' const B = 'http://localhost:8081/cgi-bin/koha/mainpage.pl' ctx.restore('remove the curl session files', () => ctx.sh(`rm -f ${J} /tmp/kbv24*`)) ctx.sh(`rm -f ${J}; curl -s -c ${J} -b ${J} ${B} -o /tmp/kbv24l.html T=$(grep -o 'name="csrf_token" value="[^"]*"' /tmp/kbv24l.html | head -1 | sed 's/.*value="//;s/"//') curl -s -c ${J} -b ${J} -d "login_userid=koha&login_password=koha&login_op=cud-login&koha_login_context=intranet" --data-urlencode "csrf_token=$T" ${B} -o /dev/null`) const api = (embed) => ctx.sh(`curl -s -c ${J} -b ${J} -H "Accept: application/json" ${embed ? `-H "x-koha-embed: ${embed}"` : ''} -o /tmp/kbv24.json -w '%{http_code}' "http://localhost:8081/api/v1/biblios/${bn}/items?_page=1&_per_page=20"; echo; cat /tmp/kbv24.json`).out ctx.sh(`(timeout 15 stdbuf -oL tail -n 0 -f ${L}/plack-api-error.log ${L}/api-error.log > /tmp/kbv24.tail 2>&1 &); sleep 2`) const bad = api(EMBED) await new Promise((r) => setTimeout(r, 14000)) const tail = ctx.sh('cat /tmp/kbv24.tail').out ctx.check('the items table\'s own request answers 500 {"error":"Something went wrong, check Koha logs for details.","error_code":"internal_server_error"}', bad === '500\n{"error":"Something went wrong, check Koha logs for details.","error_code":"internal_server_error"}', bad.slice(0, 200)) ctx.check('tail -n 0 -f: the two file headers, then under plack-api-error.log "[date] [ERROR] GET /api/v1/biblios//items: unhandled exception (Mojo::Exception)<>" (one line, two spaces)', tail.startsWith(`==> ${L}/plack-api-error.log <==\n\n==> ${L}/api-error.log <==\n`) && new RegExp(`==> ${L}/plack-api-error\\.log <==\\n\\[\\d{4}/\\d\\d/\\d\\d \\d\\d:\\d\\d:\\d\\d\\] \\[ERROR\\] GET /api/v1/biblios/${bn}/items: unhandled exception \\(Mojo::Exception\\)<>`).test(tail), tail) ctx.check('nothing in api-error.log or intranet-error.log for it (the log is plack-api-error.log)', !/==> \S+\/api-error\.log <==\n\[/.test(tail)) ctx.check('the same call without home_library/holding_library in the embed answers 200', api('+strings').startsWith('200\n')) const inc = ctx.sh(`koha-shell -c "perl ${ctx.sh(`test -d /kohadevbox/koha && echo /kohadevbox/koha/misc || echo /usr/share/koha/bin`).out}/maintenance/search_for_data_inconsistencies.pl" ${I} 2>&1`, { timeout: 600000 }).out ctx.check('search_for_data_inconsistencies.pl: the "== Not defined items.homebranch and/or items.holdingbranch ==" section names item 1 ("does not have a holding library defined") and ends "=> Edit these items and set valid homebranch and/or holdingbranch", with other sections around it', /== Not defined items\.homebranch and\/or items\.holdingbranch ==\n(\t\* Item with itemnumber=\d+ does not have [^\n]+\n)*\t\* Item with itemnumber=1 does not have a holding library defined\n(\t\* Item with itemnumber=\d+ does not have [^\n]+\n)*=> Edit these items and set valid homebranch and\/or holdingbranch/.test(inc) && !inc.startsWith('== Not defined items'), inc.slice(0, 400)) ctx.check('… "does not have home and holding library defined" is the wording when both are missing (item 2114 on kohadev)', /\t\* Item with itemnumber=\d+ does not have home and holding library defined/.test(inc)) const q = ctx.sh(`koha-mysql ${I} -e "SELECT itemnumber, biblionumber, barcode, homebranch, holdingbranch \\ FROM items WHERE homebranch IS NULL OR holdingbranch IS NULL;"`).out ctx.check('the SQL (two lines joined by a backslash) → header "itemnumber\\tbiblionumber\\tbarcode\\thomebranch\\tholdingbranch" and item 1 with holdingbranch NULL', q.startsWith('itemnumber\tbiblionumber\tbarcode\thomebranch\tholdingbranch\n') && new RegExp(`^1\\t${bn}\\t\\S+\\t\\S+\\tNULL$`, 'm').test(q), q) }