Skip to content

Query for advanced object selector does not use query_params defined on input #18727

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

Open
atownson opened this issue Feb 24, 2025 · 2 comments
Open
Labels
pending closure Requires immediate attention to avoid being closed for inactivity severity: low Does not significantly disrupt application functionality, or a workaround is available status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@atownson
Copy link
Contributor

atownson commented Feb 24, 2025

Deployment Type

NetBox Cloud

NetBox Version

v4.2.4

Python Version

3.12

Steps to Reproduce

Create two Sites and attempt to create a Virtual Machine scoped to conflicting Sites for fields site and cluster.

  1. Create 2 Sites: "My Site" and "Your Site"
  2. Create a Cluster Role: "My Role"
  3. Create a Cluster ("My Cluster") and assign it to "My Site"
  4. Create a Virtual Machine and assign it to "Your Site" and use the advanced object selector for the Cluster input to assign it to "My Cluster"

Expected Behavior

User should be unable to assign "My Cluster" because the Cluster is scoped to "My Site" and the Virtual Machine is scoped to "Your Site".

The query_params defined on the Virtual Machine's cluster input should prevent this:

query_params={
'site_id': ['$site', 'null']
},

Observed Behavior

While the cluster input itself does filter out the "My Cluster" option, selecting the Advanced Object Selector allows the selection of "My Cluster". Attempting to create the Virtual Machine scoped to the "My Cluster" Cluster returns an error:

Image

The scope of this issue is currently limited to form inputs that utilize both the selector=True and query_params={...} attributes. But with the acceptance of issues #18138 and #17944 this could be impactful to user-defined scripts and custom fields.

@atownson atownson added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Feb 24, 2025
@jeremystretch
Copy link
Member

Upon initial review, it appears that we'll need to pass the query parameters associated with the form field when sending the HTMX request to populate the advanced selection widget. This might be a bit tricky, as (unlike the field itself) we're not applying these filters directly, but rather passing them for reference to be employed when initializing the widget form. But it should be doable.

@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Feb 28, 2025
Copy link
Contributor

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 github-actions bot added the pending closure Requires immediate attention to avoid being closed for inactivity label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending closure Requires immediate attention to avoid being closed for inactivity severity: low Does not significantly disrupt application functionality, or a workaround is available status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants