netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Invalid version request parameter to S3 storage for static files

Open dominikspiertz opened this issue 7 months ago • 1 comments

Deployment Type

Self-hosted

NetBox Version

v4.3.1

Python Version

3.12

Steps to Reproduce

  1. Configure Netbox to use S3 object storage for static files
  2. Access the Netbox instance, trying to fetch static files to serve the application

Expected Behavior

Netbox should create requests to the S3 storage backend for fetching static files using valid query parameters.

Observed Behavior

Netbox attaches a query parameter with the application version using the wrong delimiter. This is the request:

https://s3.netbox.tld/files/setmode.js?AWSAccessKeyId=key&Signature=123&Expires=1748635659?v=4.3.1 See how it attaches ?v=4.3.1 at the end. When in fact it need to be &v=4.3.1

However this only happens when I try to load Netbox application. When I am on the "Static Media Failure" site, it provides a link that it cannot load the file "setmode.js". If I click there, the link works fine: https://s3.netbox.tld/files/setmode.js?AWSAccessKeyId=key&Signature=123&Expires=1748635660

dominikspiertz avatar May 30 '25 19:05 dominikspiertz

The issue appears to be the way we attach the version designation to the URL in the template:

<script src="{% static 'setmode.js' %}?v={{ settings.RELEASE.version }}" ...>

AFAIK Django's static tag doesn't allow for the inclusion of additional query parameters. Not sure what the best fix would be; we might need to override the stock tag to inspect the URL.

jeremystretch avatar Jun 02 '25 18:06 jeremystretch

@dominikspiertz would you be able to test PR https://github.com/netbox-community/netbox/pull/20455 it should hopefully fix this issue.

arthanson avatar Sep 30 '25 00:09 arthanson