Skip to content

Script run responses include storage backend error text #88

Closed

Description

@jnovinger

Plugin Version

v0.0.1 (also present on main)

NetBox Version

v4.7.4

Python Version

3.12

Steps to Reproduce

  1. Use the default filesystem storage backend for script source.
  2. Activate a revision for an upload project so it has a runnable Script.
  3. Make that revision's stored files unreadable by the NetBox process, and clear the local runtime cache so the run has to read from storage.
  4. Run the Script through the REST API (POST /api/plugins/scripts/scripts/<id>/run/), or from its run view in the UI.

Expected Behavior

The response says the Script could not be loaded, without storage backend details. The full error goes to the server log for the administrator.

Observed Behavior

Found by reading the code on main, not by running these steps. The example message below shows the shape the code produces, not captured output.

The load failure is shown to the user by api/views.py:351-358 (REST) and views/scripts.py:198 (UI). It comes from script_class_context, which passes the error through build_error_sanitizer (validation.py:239-261). The sanitizer replaces the storage key, digest, local cache directory and runtime root, but not the storage backend's own root path or other backend text. Reading a stored file wraps the backend exception text (storage/store.py, _stream_verified), so a filesystem read failure still shows something like Permission denied: '/opt/netbox/netbox/media/<scripts root>/<storage>/<digest>/script.py'. Other backends would include their own error text, such as an S3 endpoint URL.

The upload path has the same root cause and is covered by #77. CodeQL reports this one as py/stack-trace-exposure (alert 3).

Activity

  1. added theissue type on Oct 29, 2026
  2. added
    type: bugA confirmed report of unexpected behavior in the application
    app: scriptsIssues and pull requests scoped to this plugin
    severity: lowDoes not significantly disrupt application functionality, or a workaround is available
    status: needs ownerTentatively accepted; awaiting a volunteer to commit to implementing it
    and removed
    status: needs triageThis issue is awaiting triage by a maintainer
    on Oct 29, 2026
  3. changed the title [-]Storage backend error text reaches upload and script run responses[/-] [+]Script run responses include storage backend error text[/+] on Oct 29, 2026
  4. jnovinger commented on Oct 29, 2026

    @jnovinger
    MemberAuthor

    I narrowed this to the script run path, since #77 already covers the upload path (including the ImproperlyConfigured handler). The run path differs because its errors pass through build_error_sanitizer, which strips the storage key and digest but leaves the storage backend's root path and any other backend text. Both cases come from StorageError wrapping the backend exception text, so a single fix there could close both. @pheus, feel free to fold this into #77 if that's easier.

  5. jnovinger commented on Oct 29, 2026

    @jnovinger
    MemberAuthor

    Update: #71 fixed the REST run path (it now logs the error and returns a generic message), so alert 3 is closed. What remains here is the UI run view, which still includes the raw error at netbox_scripts/views/scripts.py:202.

  6. added and removed
    complexity: lowRequires minimal effort to implement
    status: needs ownerTentatively accepted; awaiting a volunteer to commit to implementing it
    on Oct 31, 2026
  7. self-assigned this
    on Nov 6, 2026
  8. added
    status: acceptedThis issue has been accepted for implementation
    and removed on Nov 6, 2026
  9. added this to the v0.1.0 milestone on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bucket: KTLOapp: scriptsIssues and pull requests scoped to this pluginseverity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions