Skip to Main Content
Status Completed
Categories Bug
Created by Søren Darville
Created on May 3, 2023

EDIFACT Dissassemble error when number of LOOPED segments exceeds 1000

We are experiencing this error when sending EDIFACT Sales Reports to Link.

Bizbrains.Link.Base.Exceptions.LinkException: An unexpected error has occurred while disassembling the message.
---> Bizbrains.Edifact.EdifactException: Segment with name: LOC has been read 1000 times. This looks like an infinite loop. Please check both the given Edifact-document and the given xsd schema.
at Bizbrains.Edifact.KnownEdifactHandlers.MicrosoftEdifactDisassembler.HandleGroup(EdifactReader edifactReader, XmlWriter xmlWriter, Queue`1 segmentElementQueue, Queue`1 schemaElements, Int32 startLevel, SegmentBase currentSegment, SchemaElement currentSchemaElement, CancellationToken cancellationToken) in /home/vsts/work/1/s/Bizbrains.APIs/Bizbrains.Edifact/Bizbrains.Edifact/KnownEdifactHandlers/MicrosoftEdifactDisassembler.cs:line 96
at Bizbrains.Edifact.EdifactDisassemblerBase.BuildSegment(XmlWriter xmlWriter, EdifactReader edifactReader, Queue`1 schemaElements, SegmentBase currentSegment, SchemaElement currentSchemaElement, Int32 startLevel, CancellationToken cancellationToken) in /home/vsts/work/1/s/Bizbrains.APIs/Bizbrains.Edifact/Bizbrains.Edifact/EdifactDisassemblerBase.cs:line 44
at Bizbrains.Edifact.KnownEdifactHandlers.MicrosoftEdifactDisassembler.DisassembleToSingleMessages(EdifactReader edifactReader, ISchemaProvider schemaProvider, CancellationToken cancellationToken) in /home/vsts/work/1/s/Bizbrains.APIs/Bizbrains.Edifact/Bizbrains.Edifact/KnownEdifactHandlers/MicrosoftEdifactDisassembler.cs:line 54
at Bizbrains.Link.Initialize.InitializeSteps.Edifact.EdifactDisassembler.Process(ILinkMessage message, EdifactDisassemblerConfig config, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Bizbrains.Link.Initialize.Base.LinkInitializeStepBase.RaiseError(ILinkMessage message, LinkException linkException) in /home/vsts/work/1/s/Bizbrains.Link.Initialize/Bizbrains.Link.Initialize/Base/LinkInitializeStepBase.cs:line 156
at Bizbrains.Link.Initialize.Base.LinkInitializeStepBase.HandleException(ILinkMessage message, Exception ex, Action`1 unknownExAction) in /home/vsts/work/1/s/Bizbrains.Link.Initialize/Bizbrains.Link.Initialize/Base/LinkInitializeStepBase.cs:line 133
at Bizbrains.Link.Initialize.Base.LinkInitializeStepBase.Execute(IEnumerable`1 messages, CancellationToken cancellationToken) in /home/vsts/work/1/s/Bizbrains.Link.Initialize/Bizbrains.Link.Initialize/Base/LinkInitializeStepBase.cs:line 89
at Bizbrains.Link.Initialize.LinkMessageInitializer.InitializeMesssage(ILinkMessage interchangeMessage, CancellationToken token) in /home/vsts/work/1/s/Bizbrains.Link.Initialize/Bizbrains.Link.Initialize/LinkMessageInitializer.cs:line 75

I have talked to David Sand about it and it is the EDIFACT Disassembler that has a hardcoded limitation in the number of loops one SEGMENT is allowed to have.

In the example that failed here, there were more than 12000 LOC segments and LEGO expects that the number of LOOPED segments can be much highter than that.

I think we should make this limitation configurable in Link-->Settings-->Settings (there are already other EDIFACT settings available there) or we should use the limitation from the EDIFACT Schema (I am aware that the limitations from the EDIFACT Schemas are often much higher than what is normal in real world scenarios and a need for another limitation could make sense).

Note: I think it is important, that while fixing this issue, that you also check if we have similar limitations in the X12 Disassembler, and apply the same solution there.

  • Attach files
  • Admin
    Nicolai Krog
    Reply
    |
    May 3, 2023

    Hi Søren.


    Can you please provide schema and example file?