CiscoTestAutomation / pyats

Cisco DevNet pyATS Test Framework Bug Tracker
Apache License 2.0
152 stars 32 forks source link

learn STP crashes with error UnboundLocalError: local variable 'inst_dict' referenced before assignment #213

Closed geertn444 closed 1 year ago

geertn444 commented 1 year ago

Crash happens in line 720 of /usr/local/lib/python3.9/site-packages/genie/libs/parser/iosxe/show_spanning_tree.py I traced the error to match condition p1

initial regexp pattern

    p1 = re.compile(r'^\#+ +MST(?P<inst>\d+) +'
                    r'vlans +mapped: +(?P<vlan>[\d\-\,\s]+)$')

it only matches digits and numbers, like

MST0 vlans mapped: 1-9,11-99,101-4094

However, it is possible that MST0 matches not a single VLAN. In that case, the switch returns:

MST0 vlans mapped: none

when this happens, script crashes

geertn444 commented 1 year ago

quick fix:

p1 = re.compile(r'^\#+ +MST(?P<inst>\d+) +'
                    r'vlans +mapped: +(?P<vlan>[\d\-\,\s\bnone\b]+)$')
SohanTirpude commented 1 year ago

Hello @geertn444,

I will be working on your ticket. Thanks for providing quick fix as well. I'll get back to you once I have any update on it.

SohanTirpude commented 1 year ago

Hello @geertn444,

Would you like to make these changes yourself that you suggested and make a contribution to the genieparser repo?

A guide for writing, testing, and contributing parser can be found here https://pubhub.devnetcloud.com/media/pyats-development-guide/docs/writeparser/writeparser.html.

or Please provide the full device output with command used.

SohanTirpude commented 1 year ago

Hello @geertn444,

Kindly provide me full device output along with the command used.

SohanTirpude commented 1 year ago

Hello @geertn444,

You are not responding, hence I am closing this ticket, but If you are still facing the same issue, kindly let me know, I'll re-open the ticket.