Filter on the assigned VRF of prefixes and adresses is lost when displaying results #6285

Closed
opened 2025-12-29 19:38:54 +01:00 by adam · 7 comments
Owner

Originally created by @DetunizedGravity on GitHub (Apr 1, 2022).

NetBox version

v3.1.7

Python version

3.8

Steps to Reproduce

  1. Create one VRF object named TEST.
  2. Create the IP address 1.1.1.1/32 without assigning a VRF.
  3. Create the IP address 2.2.2.2/32 and assign it the TEST VRF.
  4. Go to the IP address list.
  5. Go to the filter tab.
  6. In the "Assign VRF" filter choose "Global"
  7. Clic on "search".
  8. Search results are displayed.
  9. Go to the filter tab.
  10. Clic on "search" again.
  11. New search results are displayed.
  12. Go to the filter tab.

Expected Behavior

On step 8, I expect only the address 1.1.1.1/32 to be displayed. I also expect the number "1" in a blue disc on the label of the "filter".
On step 9, I expect to see the exact same filter to be displayed as on step 6 (Assigned VRF = Global).
On step 11, I expect the displayed results to be exactly the same as on step 8.
On step 12, I expect the same display as on step 6 and 9.

Observed Behavior

Step 8 is OK.
On step 9, the Assigned VRF filter is empty.
On step 11, I see both IP addresses and there is no blue disc in the label of the "filter" tab.
On step 12, I see the same empty filter form as in step 9, obviously.

I would infer that the "vrf_id" value "null" in the URL is ignored or improperly parsed by the code that prepopulates the filtering form, while it is correctly handled by the code that counts the number of active filters. It is worth noting that this does not happen with other values of the vrf_id parameter. In other words, filtering on any other VRF than the GRT behaves correctly.

My wild guess would be that that the parser expects a numerical value for the vrf_id parameter, and chokes on "null".

Note: I am not certain of the version of Python we are using, and can't seem to obtain the information in a timely manner. I will provide it ASAP.

Originally created by @DetunizedGravity on GitHub (Apr 1, 2022). ### NetBox version v3.1.7 ### Python version 3.8 ### Steps to Reproduce 1. Create one VRF object named TEST. 2. Create the IP address 1.1.1.1/32 without assigning a VRF. 3. Create the IP address 2.2.2.2/32 and assign it the TEST VRF. 4. Go to the IP address list. 5. Go to the filter tab. 6. In the "Assign VRF" filter choose "Global" 7. Clic on "search". 8. Search results are displayed. 9. Go to the filter tab. 10. Clic on "search" again. 11. New search results are displayed. 12. Go to the filter tab. ### Expected Behavior On step 8, I expect only the address 1.1.1.1/32 to be displayed. I also expect the number "1" in a blue disc on the label of the "filter". On step 9, I expect to see the exact same filter to be displayed as on step 6 (Assigned VRF = Global). On step 11, I expect the displayed results to be exactly the same as on step 8. On step 12, I expect the same display as on step 6 and 9. ### Observed Behavior Step 8 is OK. On step 9, the Assigned VRF filter is empty. On step 11, I see both IP addresses and there is no blue disc in the label of the "filter" tab. On step 12, I see the same empty filter form as in step 9, obviously. I would infer that the "vrf_id" value "null" in the URL is ignored or improperly parsed by the code that prepopulates the filtering form, while it is correctly handled by the code that counts the number of active filters. It is worth noting that this does **not** happen with other values of the vrf_id parameter. In other words, filtering on any other VRF than the GRT behaves correctly. My wild guess would be that that the parser expects a numerical value for the vrf_id parameter, and chokes on "null". Note: I am not certain of the version of Python we are using, and can't seem to obtain the information in a timely manner. I will provide it ASAP.
adam added the type: bugstatus: needs ownerpending closure labels 2025-12-29 19:38:54 +01:00
adam closed this issue 2025-12-29 19:38:54 +01:00
Author
Owner

@DetunizedGravity commented on GitHub (Apr 1, 2022):

It might also be that the form generator treats null values the same way as the paramter not being present.

@DetunizedGravity commented on GitHub (Apr 1, 2022): It might also be that the form generator treats null values the same way as the paramter not being present.
Author
Owner

@DetunizedGravity commented on GitHub (Apr 10, 2022):

I bet the problem is simply this:
Filter and lookup expression mismatch (in, range, isnull)
Unfortunately I am still trying to build myself a proper dev environment and learn enough of git to make a proper PR.

@DetunizedGravity commented on GitHub (Apr 10, 2022): I bet the problem is simply this: [Filter and lookup expression mismatch (in, range, isnull)](https://django-filter.readthedocs.io/en/stable/guide/tips.html#filter-and-lookup-expression-mismatch-in-range-isnull) Unfortunately I am still trying to build myself a proper dev environment and learn enough of git to make a proper PR.
Author
Owner

@jeremystretch commented on GitHub (Apr 12, 2022):

The root issue is that the VRF selection field is rendered without any options by default, so it's not being initialized with the VRF set to global. Work is likely needed on DynamicModelChoiceMixin to allow for this.

@jeremystretch commented on GitHub (Apr 12, 2022): The root issue is that the VRF selection field is rendered without any options by default, so it's not being initialized with the VRF set to global. Work is likely needed on DynamicModelChoiceMixin to allow for this.
Author
Owner

@DetunizedGravity commented on GitHub (Apr 26, 2022):

I'm not so sure about that. I'm starting to think that the issue lies in the rendering code for the widget, as executed in the browser. Let's suppose I want to filter the prefixes that either belong to, say, "vrf1" and to no VRF at all: if I try to select "Global" before "vrf1" as a filter, "global" instantly disappears from the form when I select "vrf1" (Edit: it's even worse: "Global" disappears as soon as I click again to display the drop-down list). On the other hand, if I select "vrf1" first then the field succeeds at displaying both "vrf1" and "Global". Now, since DynamicModelMultipleChoiceField always moves the "None" value to the first position when processing parameters, it always removes it from the displayed values when executing the search.
Put shortly, the issue occurs in browser processing of the selected filters, on each widget update. Which is why the number of selected filters on the tab is correctly computed: this is done before display of the filters themselves.

Edit: typing is hard in the morning when you've watched one too many Star Trek episode the night before.

@DetunizedGravity commented on GitHub (Apr 26, 2022): I'm not so sure about that. I'm starting to think that the issue lies in the rendering code for the widget, as executed in the browser. Let's suppose I want to filter the prefixes that either belong to, say, "vrf1" **and** to no VRF at all: if I try to select "Global" **before** "vrf1" as a filter, "global" **instantly disappears from the form** when I select "vrf1" (Edit: it's even worse: "Global" disappears as soon as I click again to display the drop-down list). On the other hand, if I select "vrf1" **first** then the field succeeds at displaying both "vrf1" and "Global". Now, since *DynamicModelMultipleChoiceField* always moves the "None" value to the first position when processing parameters, it **always** removes it from the displayed values when executing the search. Put shortly, the issue occurs in browser processing of the selected filters, on each widget update. Which is why the number of selected filters on the tab is correctly computed: this is done before display of the filters themselves. Edit: typing is hard in the morning when you've watched one too many Star Trek episode the night before.
Author
Owner

@DetunizedGravity commented on GitHub (Apr 29, 2022):

Just checked. The issue is present in almost all multiple selection fields that allow selecting a null type value. Platforms, tenant groups, tenants, racks...

Surprisingly, cable status works correctly. I can't check right now what is the difference with the others (commuting). I will have a look at a later time.

@DetunizedGravity commented on GitHub (Apr 29, 2022): Just checked. The issue is present in almost all multiple selection fields that allow selecting a null type value. Platforms, tenant groups, tenants, racks... Surprisingly, cable status works correctly. I can't check right now what is the difference with the others (commuting). I will have a look at a later time.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 29, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jun 29, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Jul 29, 2022):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Jul 29, 2022): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6285