Server error when creating permission constraints for extras > script #9260

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

Originally created by @julianstolp on GitHub (Feb 16, 2024).

Originally assigned to: @abhi1693 on GitHub.

Deployment Type

Self-hosted

NetBox Version

v3.7.2

Python Version

3.10

Steps to Reproduce

  1. Create Script
from extras.scripts import *
class TestScript(Script):

    class Meta:
        name = "TestScript"
        description = "Just for testing"

    def run(self, data, commit):
        return "Test"

API-View:
image

  1. Go to /users/permissions/add/ and create a viewing permission for Extras > Script with the following constraint. Keep in mind Choices are: id only
  2. We are creating two seperate errors so two constraints needed
    • First: {"id": "test.TestScript"} -> Got id from /api/extras/scripts/test.TestScript/
    • Second: {"id": 1} -> Just a number, because first error said a number is expected

The goal was to create a permission for a group to see only a selected script.

Expected Behavior

One of the constraints should work and create a permission to see the selected script.

Observed Behavior

  1. Constraint {"id": "test.TestScript"}
    image
  2. Constraint {"id": 1}
    image
Originally created by @julianstolp on GitHub (Feb 16, 2024). Originally assigned to: @abhi1693 on GitHub. ### Deployment Type Self-hosted ### NetBox Version v3.7.2 ### Python Version 3.10 ### Steps to Reproduce 1. Create Script ``` from extras.scripts import * class TestScript(Script): class Meta: name = "TestScript" description = "Just for testing" def run(self, data, commit): return "Test" ``` API-View: ![image](https://github.com/netbox-community/netbox/assets/41152397/3a15656e-7a47-41a3-a2f8-868903ed745a) 2. Go to `/users/permissions/add/` and create a viewing permission for `Extras > Script` with the following constraint. Keep in mind `Choices are: id` only 3. We are creating two seperate errors so two constraints needed - First: `{"id": "test.TestScript"}` -> Got id from `/api/extras/scripts/test.TestScript/` - Second: {"id": 1} -> Just a number, because first error said a number is expected The goal was to create a permission for a group to see only a selected script. ### Expected Behavior One of the constraints should work and create a permission to see the selected script. ### Observed Behavior 1. Constraint `{"id": "test.TestScript"}` ![image](https://github.com/netbox-community/netbox/assets/41152397/2ae88fe0-603c-4e96-87db-828625ea08b0) 2. Constraint `{"id": 1}` ![image](https://github.com/netbox-community/netbox/assets/41152397/38bd0f2e-43fa-4759-be88-318ef2f57a64)
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 20:47:35 +01:00
adam closed this issue 2025-12-29 20:47:35 +01:00
Author
Owner

@jeremystretch commented on GitHub (Feb 20, 2024):

This is not currently supported as reports and scripts don't map to actual database objects. However, this is changing in NetBox v4.0 (see #14438). In the interim, we could simply disable constraints for permissions targeting reports or scripts.

@jeremystretch commented on GitHub (Feb 20, 2024): This is not currently supported as reports and scripts don't map to actual database objects. However, this is changing in NetBox v4.0 (see #14438). In the interim, we could simply disable constraints for permissions targeting reports or scripts.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9260