Description
Tomás Cohen Arazi (tcohen)
2025-09-30 19:27:25 UTC
Created attachment 187120 [details] [review] Bug 40915: Add comprehensive regression tests for SIP MsgType message parsing and debug logging These tests verify that C4::SIP::Sip::MsgType correctly parses SIP messages without creating problematic arrayref field values, and validates enhanced debug logging for empty critical fields. Test Coverage: • Message parsing with correct protocol versions (PATRON_INFO/HOLD/RENEW use v2, CHECKOUT uses v1) • Empty patron_id and item_id field detection with debug logging • Malformed delimiter handling (double delimiters, trailing empty fields) • Multiple consecutive empty fields in single message • Confusing delimiter patterns that could break parsing • Verification that parsed fields are strings, not arrayrefs • Working siplog mock infrastructure in C4::SIP::Sip::MsgType Arrayref Prevention Tests: Tests verify message parsing DOESN'T create empty arrayrefs that would later cause "Odd number of elements in anonymous hash" errors when passed to Koha::Objects->find() operations. Enhanced Debug Logging Tests: Tests validate that empty critical fields (patron_id, item_id) are detected during parsing and generate appropriate debug messages to help troubleshoot downstream constraint errors. Created attachment 187121 [details] [review] Bug 40915: Add enhanced debug logging for empty critical fields in SIP message parsing This patch adds debug logging to C4::SIP::Sip::MsgType::_initialize() to help identify when critical fields (patron_id, item_id) are parsed as empty values. Empty critical fields in SIP messages can later cause DBIx::Class constraint errors when passed to Koha::Objects->find() operations, generating confusing 'Odd number of elements in anonymous hash' errors in SIP server logs. The enhanced logging helps administrators identify the root cause by logging when empty patron_id or item_id fields are detected during message parsing. To test: 1. Apply regression tests patch first 2. Run: $ ktd --shell k$ prove t/db_dependent/SIP/MsgType.t => FAIL: Debug logging tests fail (no enhanced logging present) 3. Apply this patch 4. Run: $ ktd --shell k$ prove t/db_dependent/SIP/MsgType.t => SUCCESS: All tests pass, debug logging works correctly 5. Sign off :-D Created attachment 187182 [details] [review] Bug 40915: Add comprehensive regression tests for SIP MsgType message parsing and debug logging These tests verify that C4::SIP::Sip::MsgType correctly parses SIP messages without creating problematic arrayref field values, and validates enhanced debug logging for empty critical fields. Test Coverage: • Message parsing with correct protocol versions (PATRON_INFO/HOLD/RENEW use v2, CHECKOUT uses v1) • Empty patron_id and item_id field detection with debug logging • Malformed delimiter handling (double delimiters, trailing empty fields) • Multiple consecutive empty fields in single message • Confusing delimiter patterns that could break parsing • Verification that parsed fields are strings, not arrayrefs • Working siplog mock infrastructure in C4::SIP::Sip::MsgType Arrayref Prevention Tests: Tests verify message parsing DOESN'T create empty arrayrefs that would later cause "Odd number of elements in anonymous hash" errors when passed to Koha::Objects->find() operations. Enhanced Debug Logging Tests: Tests validate that empty critical fields (patron_id, item_id) are detected during parsing and generate appropriate debug messages to help troubleshoot downstream constraint errors. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Created attachment 187183 [details] [review] Bug 40915: Add enhanced debug logging for empty critical fields in SIP message parsing This patch adds debug logging to C4::SIP::Sip::MsgType::_initialize() to help identify when critical fields (patron_id, item_id) are parsed as empty values. Empty critical fields in SIP messages can later cause DBIx::Class constraint errors when passed to Koha::Objects->find() operations, generating confusing 'Odd number of elements in anonymous hash' errors in SIP server logs. The enhanced logging helps administrators identify the root cause by logging when empty patron_id or item_id fields are detected during message parsing. To test: 1. Apply regression tests patch first 2. Run: $ ktd --shell k$ prove t/db_dependent/SIP/MsgType.t => FAIL: Debug logging tests fail (no enhanced logging present) 3. Apply this patch 4. Run: $ ktd --shell k$ prove t/db_dependent/SIP/MsgType.t => SUCCESS: All tests pass, debug logging works correctly 5. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Created attachment 187667 [details] [review] Bug 40915: Add comprehensive regression tests for SIP MsgType message parsing and debug logging These tests verify that C4::SIP::Sip::MsgType correctly parses SIP messages without creating problematic arrayref field values, and validates enhanced debug logging for empty critical fields. Test Coverage: • Message parsing with correct protocol versions (PATRON_INFO/HOLD/RENEW use v2, CHECKOUT uses v1) • Empty patron_id and item_id field detection with debug logging • Malformed delimiter handling (double delimiters, trailing empty fields) • Multiple consecutive empty fields in single message • Confusing delimiter patterns that could break parsing • Verification that parsed fields are strings, not arrayrefs • Working siplog mock infrastructure in C4::SIP::Sip::MsgType Arrayref Prevention Tests: Tests verify message parsing DOESN'T create empty arrayrefs that would later cause "Odd number of elements in anonymous hash" errors when passed to Koha::Objects->find() operations. Enhanced Debug Logging Tests: Tests validate that empty critical fields (patron_id, item_id) are detected during parsing and generate appropriate debug messages to help troubleshoot downstream constraint errors. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Created attachment 187668 [details] [review] Bug 40915: Add enhanced debug logging for empty critical fields in SIP message parsing This patch adds debug logging to C4::SIP::Sip::MsgType::_initialize() to help identify when critical fields (patron_id, item_id) are parsed as empty values. Empty critical fields in SIP messages can later cause DBIx::Class constraint errors when passed to Koha::Objects->find() operations, generating confusing 'Odd number of elements in anonymous hash' errors in SIP server logs. The enhanced logging helps administrators identify the root cause by logging when empty patron_id or item_id fields are detected during message parsing. To test: 1. Apply regression tests patch first 2. Run: $ ktd --shell k$ prove t/db_dependent/SIP/MsgType.t => FAIL: Debug logging tests fail (no enhanced logging present) 3. Apply this patch 4. Run: $ ktd --shell k$ prove t/db_dependent/SIP/MsgType.t => SUCCESS: All tests pass, debug logging works correctly 5. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Nice work everyone! Pushed to main for 25.11 |