nautobot / nautobot

Network Source of Truth & Network Automation Platform
https://docs.nautobot.com
Apache License 2.0
944 stars 254 forks source link

API endpoint `prefix-location-assignments` not able to filter by prefix UUID #5851

Open joewesch opened 4 days ago

joewesch commented 4 days ago

Environment

Steps to Reproduce

  1. Create a Prefix with a Location assigned to it
  2. Try and filter prefix to location assignments by the UUID of the prefix (e.g. api/ipam/prefix-location-assignments/?prefix=63b2b269-b33c-446e-bf34-fad097386261)

Expected Behavior

All prefix to location assignments for that prefix should be returned.

Observed Behavior

0 results are returned unless I filter by the prefix name itself (e.g. ?prefix=192.0.2.0/24)

glennmatthews commented 4 days ago

We either need to enhance the prefix method filter to handle UUIDs, or add a separate prefix_id ModelMultipleChoiceFilter. The location filter is using a NaturalKeyOrPKMultipleChoiceFilter so it's fine as-is.

Also, conversely, the VRFPrefixAssignmentFilterSet prefix filter only understands a PK, and doesn't understand a prefix string. So we should fix that too.