List Index Out of Range in message.py

113 views
Skip to first unread message

Tom Westrick

unread,
Jun 16, 2016, 1:11:45 PM6/16/16
to Bots Open Source EDI Translator
Can anyone point me in the right direction in fixing "IndexError: list index out of range"? Bots is failing on an XML file the first time it reads it in. If I re-process it, it runs fine which is why I am not sure what is wrong. It is also successful if I re-queue the original file.

Here is the full stacktrace:
Traceback (most recent call last):
 
File "c:\python27\lib\site-packages\bots\transform.py", line 71, in _translate_one_file
    edifile
.checkforerrorlist() #no exception if infile has been lexed and parsed OK else raises an error
 
File "c:\python27\lib\site-packages\bots\message.py", line 40, in checkforerrorlist
   
raise botslib.MessageError(u''.join(self.errorlist))
MessageError: Traceback (most recent call last):
 
File "c:\python27\lib\site-packages\bots\inmessage.py", line 47, in parse_edi_file
    ediobject
.initfromfile()
 
File "c:\python27\lib\site-packages\bots\inmessage.py", line 1408, in initfromfile
   
self.checkmessage(self.root,self.defmessage)
 
File "c:\python27\lib\site-packages\bots\message.py", line 98, in checkmessage
   
self._checkonemessage(node_instance,defmessage,subtranslation)
 
File "c:\python27\lib\site-packages\bots\message.py", line 108, in _checkonemessage
   
self._checkifrecordsingrammar(node_instance,structure[0],defmessage.grammarname)
 
File "c:\python27\lib\site-packages\bots\message.py", line 118, in _checkifrecordsingrammar
   
self._checkiffieldsingrammar(node_instance,structure)     #check if fields are known in grammar
 
File "c:\python27\lib\site-packages\bots\message.py", line 151, in _checkiffieldsingrammar
   
if field_definition[ISFIELD]:    #if field (no composite)
IndexError: list index out of range

-Tom

Willoughby

unread,
Jun 20, 2016, 9:18:40 AM6/20/16
to Bots Open Source EDI Translator
Complete guess here but if it works 'at a later point' I often look for either permission issues, virus scanners locking up the file (if on Windows) or some db lockup timing issue, etc. Some sort of OS I/O related issue...

Tom Westrick

unread,
Jun 21, 2016, 9:04:50 AM6/21/16
to Bots Open Source EDI Translator
It is a Windows server but it is not running any virus software.

Can anyone point to what this error is from? I looked at the code but wasn't quite following in message.py.

-Tom

henk-jan ebbers

unread,
Jun 24, 2016, 4:08:56 AM6/24/16
to bots...@googlegroups.com
hi Tom,

this is an issue with the grammar of that xml file.

I am not sure about what problem this is.
if I understand you right this failed once, and after that it did not fail any more? or is this reproducable?

kind regards,
henk-jan

On 06/16/2016 07:11 PM, Tom Westrick wrote:
> Can anyone point me in the right direction in fixing "IndexError: list index out of range"? Bots is failing on an XML file the first time it reads it in. If I re-process it, it runs fine which is
> why I am not sure what is wrong. It is also successful if I re-queue the original file.
>
> Here is the full stacktrace:
> |
> Traceback(most recent call last):
> File"c:\python27\lib\site-packages\bots\transform.py",line 71,in_translate_one_file
> edifile.checkforerrorlist()#no exception if infile has been lexed and parsed OK else raises an error
> File"c:\python27\lib\site-packages\bots\message.py",line 40,incheckforerrorlist
> raisebotslib.MessageError(u''.join(self.errorlist))
> MessageError:Traceback(most recent call last):
> File"c:\python27\lib\site-packages\bots\inmessage.py",line 47,inparse_edi_file
> ediobject.initfromfile()
> File"c:\python27\lib\site-packages\bots\inmessage.py",line 1408,ininitfromfile
> self.checkmessage(self.root,self.defmessage)
> File"c:\python27\lib\site-packages\bots\message.py",line 98,incheckmessage
> self._checkonemessage(node_instance,defmessage,subtranslation)
> File"c:\python27\lib\site-packages\bots\message.py",line 108,in_checkonemessage
> self._checkifrecordsingrammar(node_instance,structure[0],defmessage.grammarname)
> File"c:\python27\lib\site-packages\bots\message.py",line 118,in_checkifrecordsingrammar
> self._checkiffieldsingrammar(node_instance,structure)#check if fields are known in grammar
> File"c:\python27\lib\site-packages\bots\message.py",line 151,in_checkiffieldsingrammar
> iffield_definition[ISFIELD]:#if field (no composite)
> IndexError:list index outof range
> |
>
> <https://lh3.googleusercontent.com/-C3PsV-OygJk/V2Lda575jKI/AAAAAAAAEB4/O38iBDxkSq0ldZADKrsuu8wQCnsMZICFACLcB/s1600/bots_fail.PNG>
>
> <https://lh3.googleusercontent.com/-j60I2yTBu_M/V2LdhcEVA0I/AAAAAAAAECA/KYII_UUtbJw5GUI9K5-_EcNIu6RAhrKoACLcB/s1600/bots_success.PNG>
>
> -Tom
> --
> You received this message because you are subscribed to the Google Groups "Bots Open Source EDI Translator" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to botsmail+u...@googlegroups.com <mailto:botsmail+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Tom Westrick

unread,
Jun 24, 2016, 9:48:36 AM6/24/16
to Bots Open Source EDI Translator
It is reproducible but it runs fine if that is the only route being run. I am sharing recorddefs for common "objects" by including them using recorddefs.update(messages_grammar.recorddefs). This works in most cases except this one. I've temporarily fixed it by not using recorddefs.update in certain spots. A plugin would probably be best for me to create than to explain how I set it up :)

-Tom

henk-jan ebbers

unread,
Jun 24, 2016, 12:06:53 PM6/24/16
to bots...@googlegroups.com


On 06/24/2016 03:48 PM, Tom Westrick wrote:
> It is reproducible but it runs fine if that is the only route being run. I am sharing recorddefs for common "objects" by including them using recorddefs.update(messages_grammar.recorddefs).
yes, that does not work.
what do you want to achieve here?

kind regards,
henk-jan
> <https://lh3.googleusercontent.com/-C3PsV-OygJk/V2Lda575jKI/AAAAAAAAEB4/O38iBDxkSq0ldZADKrsuu8wQCnsMZICFACLcB/s1600/bots_fail.PNG>>
> >
> > <https://lh3.googleusercontent.com/-j60I2yTBu_M/V2LdhcEVA0I/AAAAAAAAECA/KYII_UUtbJw5GUI9K5-_EcNIu6RAhrKoACLcB/s1600/bots_success.PNG
> <https://lh3.googleusercontent.com/-j60I2yTBu_M/V2LdhcEVA0I/AAAAAAAAECA/KYII_UUtbJw5GUI9K5-_EcNIu6RAhrKoACLcB/s1600/bots_success.PNG>>
> >
> > -Tom
> > --
> > You received this message because you are subscribed to the Google Groups "Bots Open Source EDI Translator" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to botsmail+u...@googlegroups.com <javascript:> <mailto:botsmail+u...@googlegroups.com <javascript:>>.
> > For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.

Tom Westrick

unread,
Jun 24, 2016, 4:09:18 PM6/24/16
to Bots Open Source EDI Translator
My goal was to not have to duplicate shared recorddefs in multiple files. Most of my XML files represent C# classes which share many of the same data types. I am able to use recorddefs.update in most cases which seems to work fine. It was just one specific grammar where it was throwing the list index out of range error. I just duplicated some recorddefs to fix the problem. I am good for now! Thanks!

-Tom

henk-jan ebbers

unread,
Jun 24, 2016, 4:10:44 PM6/24/16
to bots...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages