Improve key validation for API_TOKEN_PEPPERS configuration #423

Closed
opened 2026-04-05 16:31:51 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @LeoColomb on 2/3/2026

Fixes: https://github.com/netbox-community/netbox-chart/issues/1021

YAML is a loose format, and its dictionary key type is loose too.
In a situation where the configuration is processed by an external tool, an integer might be interpreted as a string.
When passing to NetBox, this mismatch raises the ImproperlyConfigured exception.
That being said, even the message printed is confusing (1 being an integer):

django.core.exceptions.ImproperlyConfigured: Invalid API_TOKEN_PEPPERS key: 1. All keys must be integers.

This change keeps the requirements while accepting converted types.

*Originally created by @LeoColomb on 2/3/2026* <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: https://github.com/netbox-community/netbox-chart/issues/1021 <!-- Please include a summary of the proposed changes below. --> YAML is a loose format, and its dictionary key type is loose too. In a situation where the configuration is processed by an external tool, an integer might be interpreted as a string. When passing to NetBox, this mismatch raises the ImproperlyConfigured exception. That being said, even the message printed is confusing (`1` being an integer): ``` django.core.exceptions.ImproperlyConfigured: Invalid API_TOKEN_PEPPERS key: 1. All keys must be integers. ``` This change keeps the requirements while accepting converted types.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#423