xlate / staedi

StAEDI - Streaming API for EDI: Java library featuring a reader/parser, writer/generator, and validation
Apache License 2.0
127 stars 36 forks source link

Invalid Processing State - reading custom "END" segment #174

Closed benjamin-lang closed 3 years ago

benjamin-lang commented 3 years ago

Describe the bug Im trying to read a third party edifact file. While calling reader.next() the following error occurs:

io.xlate.edi.internal.stream.tokenization.EDIException: EDIE003 - Invalid processing state; INVALID (previous: TRAILER_TRADACOMS_D); input: '+' in segment UNH at position 21 
        at io.xlate.edi.internal.stream.tokenization.Lexer.error(Lexer.java:432) ~[staedi-1.16.2.jar:na] 
        at io.xlate.edi.internal.stream.tokenization.Lexer.invalidStateError(Lexer.java:427) ~[staedi-1.16.2.jar:na] 
        at io.xlate.edi.internal.stream.tokenization.Lexer.parse(Lexer.java:288) ~[staedi-1.16.2.jar:na] 
        at io.xlate.edi.internal.stream.StaEDIStreamReader.nextEvent(StaEDIStreamReader.java:170) ~[staedi-1.16.2.jar:na] 
        at io.xlate.edi.internal.stream.StaEDIStreamReader.next(StaEDIStreamReader.java:202) ~[staedi-1.16.2.jar:na] 

To Reproduce The line which produces the error looks like this: END+2+19910101++P +Test1?, Test2+0+20041017'

Expected behavior Read the file without an error.

Additional context The problem seems to be, that the creator of the edi file used the"END" segment for their custom data (Version UNOC, 3) and staedi interprets this segment as TRADACOM Dialect and cannot read it. Im not quite sure if it is a bug or not. If it is not bug, is there any workaround for me to get that thing working ?

Thanks in advance

MikeEdgar commented 3 years ago

Hi @benjamin-lang - yes this is a bug. I'll look into getting this resolved over the next few days.

benjamin-lang commented 3 years ago

Nice, thanks for the fast response 👍

MikeEdgar commented 3 years ago

@benjamin-lang - fix is in release 1.16.3. Please try in your application and let me know if you run into any issues. Thanks

benjamin-lang commented 3 years ago

Hi, I'm getting the same error ... I made a minimal example which results in the same error for me:

` UNA:+,?^'

UNB+UNOC:3+++++'

UNH+++'

END+++++++'

UNT++'

UNZ++' `

Can you reproduce the error ?

MikeEdgar commented 3 years ago

hi @benjamin-lang - the only errors I get with that input are related to missing required elements. Can you confirm the new stack trace includes version 1.16.3?

benjamin-lang commented 3 years ago

Hi @MikeEdgar, i checked the dependencies, you were right, was a problem in my intelliJ with resolving the dependency. Your fix works, thank you very much 🥇