Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for handling of alphabetic repetition separator #200

Merged
merged 3 commits into from
Jul 6, 2021

Conversation

hoffrocket
Copy link
Contributor

Problem

Valid X12 ISA headers can sometimes include an alpha-numeric character at element 11. In that case, the value should be ignored in favor of the default repetition separator "^"

We've encountered real world messages that have a V at ISA 11 fail to parse with the following error message on later events. I'm Assuming that a V was encountered elsewhere in the segments and the parser assumed that it was a control character.

io.xlate.edi.internal.stream.tokenization.EDIException: EDIE003 - Invalid processing state; INVALID (previous: TAG_1); input: 'V' in segment AMT at position 25
	at io.xlate.edi.internal.stream.tokenization.Lexer.error(Lexer.java:432)

Besides the spec, there's supporting evidence for this here: https://www.ibm.com/support/pages/isa-11-repetition-separator-letter-u-and-u-character-data-it-does-not-fail-x12-deenvelope

Fix

This change checks will elementRepeater to the default if the header value is alphabetic

an alpha-numeric reptition separator in ISA-11 should be ignored and the
default should be used.
Copy link
Member

@MikeEdgar MikeEdgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoffrocket - thanks for bringing this up and for opening the PR. I have a couple suggestions around disabling the repeater rather than defaulting it. Please have a look and let me know what you think.

@MikeEdgar
Copy link
Member

Thinking a bit more about this, what about adding this method to CharacterSet and calling instead of !Character.isAlphabetic? This will take into account other delimiters and user configuration.

    public boolean isValidDelimiter(int character) {
        switch (getClass(character)) {
        case CONTROL:
            return !extraneousIgnored;
        case WHITESPACE:
        case OTHER:
            return true;
        default:
            return false;
        }
    }

@MikeEdgar MikeEdgar added this to the v1.17.0 milestone Jul 3, 2021
@MikeEdgar MikeEdgar linked an issue Jul 3, 2021 that may be closed by this pull request
@coveralls
Copy link

Pull Request Test Coverage Report for Build 1002774612

  • 4 of 5 (80.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 98.057%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/main/java/io/xlate/edi/internal/stream/tokenization/CharacterSet.java 3 4 75.0%
Totals Coverage Status
Change from base Build 976119375: -0.02%
Covered Lines: 4795
Relevant Lines: 4890

💛 - Coveralls

@MikeEdgar MikeEdgar merged commit 91cc54b into xlate:master Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ignore invalid X12 repetition separators
3 participants