Prefilling a MultiObjectVar from the Run URL keeps only the last ID
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Start at views/scripts.py:148 and compare how the plugin builds form initial data with NetBox core's normalize_querydict usage in extras/views.py:1727. Run the view test that renders the script run page with repeated tags parameters. Done means both tag IDs are selected, not just the last one.
Written by the indexing model from the issue text.
Description
Plugin Version
v0.0.1 (also present on main)
NetBox Version
v4.7.4
Python Version
3.12
Steps to Reproduce
-
Activate a Script with a
MultiObjectVar:from extras.models import Tag from netbox_scripts import MultiObjectVar, Script class PickTags(Script): tags = MultiObjectVar(model=Tag) def run(self, data, commit): return ','.join(tag.name for tag in data['tags']) -
Create two tags (IDs 1 and 2 below).
-
Open the Script's run view with both IDs in the URL:
/plugins/netbox-scripts/scripts/<id>/run/?tags=1&tags=2.
Expected Behavior
Both tags are preselected, as they are for a built-in Script with the same URL.
Observed Behavior
Found while reviewing #86, which documents prefilling a selection from the Run URL.
Only tag 2 is preselected. With ?tags=1 alone, tag 1 is preselected as expected. Reproduced with a view test on NetBox v4.7.4 that renders the run page and reads the selected options.
views/scripts.py:148 builds the form with initial=request.GET.dict(), and QueryDict.dict() keeps only the last value of a repeated key. Core's script view uses normalize_querydict(request.GET) (extras/views.py:1727 in NetBox), and swapping that in makes the same test preselect both tags.
- Dominant language
- Python
- Stars
- 8
- Forks
- 0
- Avg merge
- 11h 23m
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from netbox-community/netbox-scripts
-
app: scripts severity: medium status: backlog type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
netbox-community/netbox-scripts#83 ·
Maintainers usually reply within 1 day
-
app: scripts status: backlog type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
netbox-community/netbox-scripts#80 ·
Maintainers usually reply within 1 day
-
app: scripts severity: medium status: backlog type: bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
netbox-community/netbox-scripts#79 ·
Maintainers usually reply within 1 day
-
app: scripts severity: medium status: backlog type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
netbox-community/netbox-scripts#77 ·
Maintainers usually reply within 1 day
-
app: scripts severity: low status: backlog type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
netbox-community/netbox-scripts#76 ·
Maintainers usually reply within 1 day
All issues in netbox-community/netbox-scripts
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
QuantConnect/Documentation#2838 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
awslabs/route53-dynamic-dns-with-lambda#67 · 1 comment ·
-
`SubAgents` returns a child run's `DeferredToolRequests` to the parent as a successful tool resultOpenbug pkg:harness
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
pydantic/pydantic-ai#12405 ·
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 82/100