https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43870 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208613 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208613&action=edit Bug 43870: Flag EDIFACT messages with no BGM instead of stopping edi_cron.pl Koha::Edifact::Message->new assumes that the second segment of a message is a BGM and that a segment follows the BGM and any DTM segments. A message with no BGM died with: Can't call method "elem" on an undefined value and one that ended after its BGM and DTM segments died in the loop that collects the DTM segments. Koha::Edifact->message_array, which builds the messages, is called by process_invoice, process_quote and process_ordrsp outside any error handling, so the exception stopped edi_cron.pl: later messages and accounts were skipped and the message was left in status 'processing'. This patch: - makes Koha::Edifact::Message->new throw Koha::Exceptions::FileNotParsed ("Message has no BGM segment") when the second segment is not a BGM, and stops the DTM loop at the end of the segments - adds Koha::EDI::_edifact_messages, used by the three process_ routines around message_array, which handles that exception as an interchange that cannot be parsed: status 'error', an edifact_errors row, a log entry, and carry on with the next message. The error recording is shared with _edifact_parser through _flag_unparsable. Test plan: 1. Apply the patch, and the patches on bug 43757 it depends on 2. prove t/Edifact.t t/db_dependent/Koha/EDI.t => they pass 3. Add an INVOICE to edifact_messages (status 'new') whose raw_msg is UNA:+.? 'UNB+UNOC:3+TEST+KOHA+200101:0000+1'UNH+1+INVOIC'UNT+1+1'UNZ+1+1' followed by a second, valid INVOICE, and run misc/cronjobs/edi_cron.pl => the first message is 'error' with a row in edifact_errors ("Message has no BGM segment"), the second is processed, and the cron completes Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.