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

Handle Integer Values in calculate_diff_on_dicts to Prevent WrongDataTypeException for ARP Table ttl #152

Closed
cdot65 opened this issue Feb 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@cdot65
Copy link
Contributor

cdot65 commented Feb 3, 2024

Describe the bug

When capturing ARP tables for comparison using calculate_diff_on_dicts, the script fails with WrongDataTypeException: Unknown value format for key ttl. This seems to occur because the ttl values in the ARP table entries are integers, and the current implementation only handles strings and dictionaries.

The behavior is inconsistent, but I believe this may only occur when a single ARP entry is returned from the device. I may misunderstand the behavior is that multiple ARP entries are stored as a dict object, thereby not having this issue occur

Expected behavior

The comparison function should handle integer values without throwing an exception, allowing the script to correctly compare ARP table entries including integer ttl values.

Current behavior

The script raises WrongDataTypeException when it encounters an integer ttl value in the ARP table data structure, leading to a failure in the comparison process.

Possible solution

A conditional check for integer types could be added to the comparison logic to handle ttl values correctly. This would involve extending the current if-else structure to include a case for handling integers, similar to how strings and dictionaries are currently processed.

Change the existing:

                    if isinstance(left_side_to_compare[key], str):
                        result["changed"]["changed_raw"][key] = dict(
                            left_snap=left_side_to_compare[key],
                            right_snap=right_side_to_compare[key],
                        )
                        item_changed = True

to:

                    if isinstance(left_side_to_compare[key], (str, int)):
                        result["changed"]["changed_raw"][key] = dict(
                            left_snap=left_side_to_compare[key],
                            right_snap=right_side_to_compare[key],
                        )
                        item_changed = True

Steps to reproduce

  1. Capture ARP table entries from a Palo Alto Networks device that includes ttl values as integers.
  2. Use the calculate_diff_on_dicts function to compare two ARP tables.
  3. Observe that the script fails with WrongDataTypeException when it encounters the ttl value.

Screenshots

2024-02-03_09-17-05 817

Context

This issue is preventing the successful comparison of ARP tables as part of an upgrade assurance process, potentially impacting the ability to verify device configurations before and after upgrades.

Your Environment

  • Version used: panos-upgrade-assurance==0.3.2, pan-os-python==1.11.0
  • Environment name and version: Python 3.11.2
  • Operating System and version: macOS
  • Link to your project: pan-os-upgrade
@alperenkose
Copy link
Collaborator

Fixed in #153 PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants