x12valid throwing TypeError: 'NoneType' object is not iterable
Opened this issue · 0 comments
pam-caton commented
I've encountered the following error when a segment has an element defined as required and that element has subelements defined. When the entire element is missing (e.g. I receive a segment in an X221 file like PLB*123*20211108~
where element 3 is required and has sub-elements), then I receive the following error:
Traceback (most recent call last):
File ".local/bin/x12valid", line 8, in <module>
sys.exit(main())
File ".local/lib/python3.6/site-packages/pyx12/scripts/x12valid.py", line 158, in main
fd_997=fd_997, fd_html=fd_html, fd_xmldoc=None, map_path=args.map_path):
File ".local/lib/python3.6/site-packages/pyx12/x12n_document.py", line 199, in x12n_document
valid &= node.is_valid(seg, errh)
File ".local/lib/python3.6/site-packages/pyx12/map_if.py", line 1013, in is_valid
valid &= child_node.is_valid(None, errh)
File ".local/lib/python3.6/site-packages/pyx12/map_if.py", line 1481, in is_valid
for sub_ele in comp_data:
TypeError: 'NoneType' object is not iterable
To fix it, I wrapped a test above the for loop at line 1481 so that if comp_data
is empty, it will skip the for-loop and continue to if not good_flag
check.