Skip to content

RecursionError in netbox_custom_objects plugin due to circular dependencies in CustomObjectType Fields #195

@Kani999

Description

@Kani999

Plugin Version

v0.2.0

NetBox Version

v4.4.0-beta1

Python Version

v3.12.3

Steps to Reproduce

  1. Create two CustomObjectType instances (e.g., Service and ServiceEndpoint).
  2. Add fields:
    • In Service, add an object type field pointing to ServiceEndpoint.
    • In ServiceEndpoint, add an object type field pointing back to Service.
  3. Access a NetBox page
  4. Observe the 500 Internal Server Error in logs.

Infinite recursion in the netbox_custom_objects plugin, specifically during template rendering for navigation. The recursion happens between CustomObjectType.get_model() and FieldType.get_model_field(), where each method repeatedly calls the other, leading to a stack overflow.

Expected Behavior

  • Validation error when creating a circular dependency in custom object definitions.
  • NetBox loads pages without errors, and custom objects resolve correctly without recursion.

Observed Behavior

  • RecursionError in Django logs, originating from CustomObjectType.get_model()_fetch_and_generate_field_attrs()get_model_field().
  • nbshell scripts attempting to inspect or delete fields also fail with recursion

Metadata

Metadata

Assignees

Labels

severity: highCompletely breaks certain functions, or substantially degrades performance application-widestatus: needs ownertype: bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions