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

lldm.py return error: current_dict[final] = value, TypeError #274

Closed
Zagrebelsky opened this issue Jun 20, 2023 · 3 comments
Closed

lldm.py return error: current_dict[final] = value, TypeError #274

Zagrebelsky opened this issue Jun 20, 2023 · 3 comments

Comments

@Zagrebelsky
Copy link
Contributor

Hi!
It looks like there might be an issue when the path_component is already a string in the dictionary.
When this happens, current_dict becomes a string, and then current_dict[final] = value, it throws the TypeError.

  File "/netbox_agent/lldp.py", line 45, in parse
    current_dict[final] = value

Expected behavior
current_dict should always be dict, and not failed

Environment:

  • OS: [e.g. Rocky 8 18.04]
  • Netbox agent version [v0.7.2]

I prepared fix.

                current_dict[path_component] = current_dict.get(path_component, {})
                current_dict = current_dict[path_component]

replace to

                if not isinstance(current_dict.get(path_component), dict):
                    current_dict[path_component] = {}
                current_dict = current_dict.get(path_component)

Thanks!

@Solvik
Copy link
Owner

Solvik commented Aug 18, 2023

Hi @Zagrebelsky

parsing LLDP output is quite tricky but your fix seems to do the trick!

it would be nice if you could open the PR so you can be the author and get the mentions! what do you think?

@Zagrebelsky
Copy link
Contributor Author

Zagrebelsky commented Aug 25, 2023

Hi @Solvik,
done #280

@Solvik
Copy link
Owner

Solvik commented Aug 28, 2023

Thanks !

@Solvik Solvik closed this as completed Aug 28, 2023
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