Skip to content

Remove version-compatibility branches unreachable at the NetBox 4.3 floor #133

Description

@marcinpsk

Summary

With the NetBox 4.3 floor now enforced (#132), three of the five version-compatibility flags can no longer be false on any supported server. The branches they guard, and core/compat.py in its entirety, are unreachable in production but still carried, threaded and tested.

Why this is more than dead code

Until #132 the test suite constructed NetBox at versions 3.5, 4.0 and 4.1 in 98 places, all below the documented minimum. Those runs made the dead branches look live: a test could pass while asserting behaviour that no supported deployment will ever execute. That is the same "green while the real path is broken" failure a mock-heavy test produces, at the scale of a compatibility layer.

#132 bumped those 98 sites to the oldest supported release, so the misleading coverage is gone. What remains is the code it was covering.

What is now constant

flag introduced for at 4.3+
modules NetBox >= 3.2 always true
new_filters NetBox >= 4.1 always true
rack_types NetBox >= 4.1 always true
m2m_front_ports NetBox >= 4.5 still varies
module_bay_types NetBox >= 4.7 still varies

m2m_front_ports and module_bay_types are genuine and must stay.

Scope

core/compat.py exists only to pick between the old and new filter key names:

return "device_type_id" if new_filters else "devicetype_id"
return "module_type_id" if new_filters else "moduletype_id"

The devicetype_id / moduletype_id side is unreachable at 4.3+. The module collapses to two constants, or disappears into its callers. Callers: core/component_cache.py (lines 316, 318, 482, 483) and core/update_failure_resolver.py (line 139).

new_filters is referenced 39 times across core/, and is threaded through the DeviceTypes, ComponentCache and NetBoxGraphQLClient constructors purely to reach those two branches.

self.modules and self.rack_types guard whether module types and rack types are processed at all: core/import_run.py lines 458, 676, 687, 741, and the summary plumbing at 44, 69, 70, 533, 758.

Suggested approach

  1. Delete core/compat.py, inline device_type_id / module_type_id at the four call sites.
  2. Remove the new_filters parameter from the three constructors and its 39 references.
  3. Remove the modules and rack_types flags and the branches they guard, keeping the behaviour of the true side.
  4. Keep m2m_front_ports and module_bay_types untouched.

Ordering

Do this after #132 merges. The 4.3 floor is what makes the removal safe; landing it first, or out of order, would drop support for servers the importer still accepts.

Not included

Whether to raise the floor further. NetBox 4.3 reached end of life upstream some time ago, and a higher floor would retire m2m_front_ports too, but that is a support-policy decision rather than a cleanup and belongs in its own discussion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions