Skip to content

Conversation

@mkyrc
Copy link

@mkyrc mkyrc commented Aug 18, 2025

SUMMARY

Fixes #560

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • iosxr_bgp_global
ADDITIONAL INFORMATION

This short code (below) uses the sorted() function. If the result of the lambda function is a list of str and integer values, the sorted() function will fail. Therefore is required result of lambda change to the same format - in this case to string.

        # transform vrfs into a list
        if vrfs:
            objs["vrfs"] = sorted(
                list(objs["vrfs"].values()),
                key=lambda k, sk="vrf": str(k[sk]),  # << change
            )
            for vrf in objs["vrfs"]:
                self._post_parse(vrf)
        else:
            objs["vrfs"] = []

Before change, the playbook task is failed with this message (when vrf names is mix of str anf int values):
"'<' not supported between instances of 'str' and 'int'"

After the change, new vrf(s) is added into router bgp configuration.

@KB-perByte
Copy link
Contributor

Hey @mkyrc thank you for your contribution,
Can you please add some unit test cases for the change suggested?

Let us know if you need any help!
cc @Ruchip16

@mkyrc
Copy link
Author

mkyrc commented Aug 20, 2025

Thanks @KB-perByte for the feedback. I would appreciate help with unit test cases.

@AAYUSH2091
Copy link
Contributor

Thanks @KB-perByte for the feedback. I would appreciate help with unit test cases.

Hi @mkyrc!

Thanks for the bug fix.
Add test cases for Mixed VRF name types: this covers the specific bug you're fixing

Unit tests should be added to:
tests/unit/modules/network/iosxr/test_iosxr_bgp_global.py

You can follow the existing test patterns in that file.

@Ruchip16 Ruchip16 self-requested a review September 10, 2025 07:39
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

Successfully merging this pull request may close these issues.

iosxr_bgp_global - unable to add new VRF, when configured VRF names within router BGP are a combination of str and int

4 participants