Permission Constraints Not Accepting Script IDs #8306

Closed
opened 2025-12-29 20:35:09 +01:00 by adam · 1 comment
Owner

Originally created by @theMachineMasse on GitHub (Jul 6, 2023).

NetBox version

v.3.5.4

Python version

3.8

Steps to Reproduce

  1. When modifying or creating a Permission for a User in the Admin menu, I have set the first few fields as such:
    image

  2. I select the Group or User I want to apply the Permission to.

  3. For the constraints, I set the field to {"id": "equipment-creation.SatelliteCreationScript"} given the following script
    image

  4. I hit the Save button to save the permission

Expected Behavior

The permission should save, making it so the User or Group only has access to run this particular script given the provided constraints.

Observed Behavior

A server error occurs: Field 'id' expected a number but got 'equipment-creation.SatelliteCreationScript'.

The expectation that the id must be a number is contradictory to the documentation and return result of the API endpoint extra_scripts_list GET. The top right part of the image that shows the script in the Steps to Reproduce indicates the ID is a string. This is further backed by doing the extract_scripts_list call, which returns the following:
image
As can be seen, the ID is a string not a number.

Originally created by @theMachineMasse on GitHub (Jul 6, 2023). ### NetBox version v.3.5.4 ### Python version 3.8 ### Steps to Reproduce 1. When modifying or creating a Permission for a User in the Admin menu, I have set the first few fields as such: ![image](https://github.com/netbox-community/netbox/assets/55885611/d203718f-e330-4b89-9e0f-46fcf2bc9d8f) 2. I select the Group or User I want to apply the Permission to. 2. For the constraints, I set the field to `{"id": "equipment-creation.SatelliteCreationScript"}` given the following script ![image](https://github.com/netbox-community/netbox/assets/55885611/b1ad8bdf-3d73-428d-b67f-e4eef4d9471e) 3. I hit the Save button to save the permission ### Expected Behavior The permission should save, making it so the User or Group only has access to run this particular script given the provided constraints. ### Observed Behavior A server error occurs: `Field 'id' expected a number but got 'equipment-creation.SatelliteCreationScript'.` The expectation that the id must be a number is contradictory to the documentation and return result of the API endpoint extra_scripts_list GET. The top right part of the image that shows the script in the Steps to Reproduce indicates the ID is a string. This is further backed by doing the extract_scripts_list call, which returns the following: ![image](https://github.com/netbox-community/netbox/assets/55885611/38dfd17c-1d80-4f66-8e37-af90e95d2312) As can be seen, the ID is a string not a number.
adam closed this issue 2025-12-29 20:35:09 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Jul 8, 2023):

Script is not a real model, and as such permission constraints do not work on it, because permission constraints are pretty much just QuerySet filters. However you might be able to do something with Core -> ManagedFile, either with the ìd` field (numeric) or the file path field.

This is not a bug, and while it's probably not going to change, the right way to change it would be a feature request and not a bug report.

@kkthxbye-code commented on GitHub (Jul 8, 2023): `Script` is not a real model, and as such permission constraints do not work on it, because permission constraints are pretty much just QuerySet filters. However you might be able to do something with Core -> ManagedFile, either with the ìd` field (numeric) or the file path field. This is not a bug, and while it's probably not going to change, the right way to change it would be a feature request and not a bug report.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8306