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

TOO_MANY_COMPONENTS BUG #49

Closed
josecaster opened this issue Jul 5, 2020 · 7 comments
Closed

TOO_MANY_COMPONENTS BUG #49

josecaster opened this issue Jul 5, 2020 · 7 comments

Comments

@josecaster
Copy link

Hi,

I have had this issue for over a week now and I though to myself, let me consult you guys about it. I have a transaction schema that validates the codeco 95b. Here is a zip file containing the edi file and the transaction file.
edi.zip

What happens is on the TDT segment I get an error TOO_MANY_COMPONENTS staring from element 8178. What I suspect happening is that the error itself act as an component and for that reason the componentIndex cannot be the "componentPosition - 1" but needs to be "componentPosition -2"
Screenshot_11

I Suspect that for various reasons. The code you sent me earlier in a question I had about errors I also needed to fix the error there as I received outOfBound exceptions. See code below:
"
if (segment == null && transactionSchema != null) {
segment = (EDIComplexType) transactionSchema.getType(location.getSegmentTag());
}
if (segment != null) {
// Obtain an EDIReference for the current element from the segment's list of
// elements
EDIReference reference = segment.getReferences().get(location.getElementPosition() - 1);
ediWriteElement.setReference(reference);

		// The element will be either an EDISimpleType (i.e. a simple element) or an
		// EDIComplextType (if it is a composite element)
		EDIType element = reference.getReferencedType();
		if (element instanceof EDIComplexType) {
			List<EDIReference> references = ((EDIComplexType) element).getReferences();
			try {
				EDIReference componentRef = references.get(**location.getComponentPosition() - 2**);
				EDISimpleType component = (EDISimpleType) componentRef.getReferencedType();
				ediWriteElement.setSimpleType(component);
				System.out.println("Not Normal Type");
			} catch (IndexOutOfBoundsException e) {
				e.printStackTrace();
			}
		} else {
			ediWriteElement.setSimpleType((EDISimpleType) element);
			System.out.println("Normal Type");
		}
	} else {
		ediWriteElement.setRemedy("No element type defined for location [" + location + "]");
	}

"
Screenshot_12

Another platform where I also test my files has no errors on the TDT;

reference:

Screenshot_10

I hope I have explained this issue very well, let me know If there is anymore information I can provide

@josecaster
Copy link
Author

On another note, Forgot to mention this. The error might not be with the "-2" but if you look at the last screenshot, the reader sees the value "20" of code 3055 as an element of c228. c288 as only 2 elements and the value 20 is on the 3th element of c040. I think there is the real issue as opposed to what I said earlier.

@MikeEdgar
Copy link
Member

@josecaster - thanks for reporting. I'll let you know what I find as soon as I can.

@MikeEdgar
Copy link
Member

@josecaster - are you using version 1.7.1? In a quick test I did not get the error using 1.7.1 or the current 1.8 development version in the master branch.

@MikeEdgar
Copy link
Member

Hi @josecaster - were you able to get it working?

@josecaster
Copy link
Author

Hey,

Sorry for the late reply, I wasn't aware that you already replied. I am using version 1.7.1. I think I know why you didn't get the error. There was an error in the date of the UNH and needed to fix that before the Validator unfolds other errors. Can you please test with this new file. And if it works should I use 1.8?
edi.zip

@MikeEdgar
Copy link
Member

MikeEdgar commented Jul 7, 2020

@josecaster, I am still not able to reproduce it with the new file (I do get an "element too short error though" on the UNB date). The date length is 8 chars since the UNB01.2 is version 4.

I also added this to the schema for the CNT segment that is located before the UNT.

  <elementType name="6066" base="decimal" maxLength="18"/>
  <elementType name="6069" base="string" maxLength="3"/>

  <compositeType name="C270">
    <sequence>
      <element type="6069" minOccurs="1"/>
      <element type="6066" minOccurs="1"/>
      <element type="6411" />
    </sequence>
  </compositeType>

  <segmentType name="CNT">
    <sequence>
      <composite type="C270" minOccurs="1"/>
    </sequence>
  </segmentType>

If there is any way you can send more of your application code or a small example program that reproduces the issue, I can dig deeper.

Version 1.8 is not yet released. There are a few more features I'd like to incorporate and there is a new version of the schema format (xmlns v4).

@josecaster
Copy link
Author

Found the issue on my side. Thanks for the support. Very quick feedback, it was no issue at all.

FYI I forgot that I wasn't validating the same file but I was validating a file which I rewrote and since there was an issue with the rewritten addition I experienced the issues. Thanks again for the support.

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

No branches or pull requests

2 participants