Skip to content

Error key from returned dict incorrectly passed as argument to dynamically created dataclass #861

Description

@huacchob

Environment

  • Python version: 3.11
  • netutils version: 1.17.1

Expected Behavior

When I run the netutils.nist._os_platform_object_builder function, I expect this to properly call the dynamically created dataclass.

Observed Behavior

If the netutils.os_version.version_metadata function is called, and the version can't be properly parsed, a dictionary is returned instead, which contains the Error key. This would then get added to the dynamically created dataclass, and we get an unexpected keyword argument error, a TypeError.

Steps to Reproduce

from netutils.nist import _os_platform_object_builder as builder
builder(vendor="Cisco", platform="ios", version="03.03.05SE")
Traceback (most recent call last):
File "", line 1, in
File "/opt/nautobot/lib64/python3.11/site-packages/netutils/nist.py", line 231, in _os_platform_object_builder
return platform_cls(**field_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: CiscoIos.init() got an unexpected keyword argument 'Error'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions