Object of type User is not JSON serializable #10008

Closed
opened 2025-12-29 21:25:32 +01:00 by adam · 2 comments
Owner

Originally created by @sysdagenaim on GitHub (Jul 24, 2024).

Originally assigned to: @bctiemann on GitHub.

Deployment Type

Self-hosted

NetBox Version

v3.7.6

Python Version

3.12

Steps to Reproduce

I created a custom_field for device roles content type named "created_by" .
It accepts Users > User as object type.
After I have created a permission with {"custom_field_data__created_by": "$user"} as constraint, I get 'Object of type User is not JSON serializable' when I try to either change or delete a device role created by myself. Putting my user id instead of "$user" works as expected.

Expected Behavior

Constraint with {"custom_field_data__created_by": "$user"} should recognize the User token

Observed Behavior

The user token "$user" is not recognized and I get 'Object of type User is not JSON serializable'

Originally created by @sysdagenaim on GitHub (Jul 24, 2024). Originally assigned to: @bctiemann on GitHub. ### Deployment Type Self-hosted ### NetBox Version v3.7.6 ### Python Version 3.12 ### Steps to Reproduce I created a custom_field for device roles content type named "created_by" . It accepts Users > User as object type. After I have created a permission with {"custom_field_data__created_by": "$user"} as constraint, I get 'Object of type User is not JSON serializable' when I try to either change or delete a device role created by myself. Putting my user id instead of "$user" works as expected. ### Expected Behavior Constraint with {"custom_field_data__created_by": "$user"} should recognize the User token ### Observed Behavior The user token "$user" is not recognized and I get 'Object of type User is not JSON serializable'
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:25:33 +01:00
adam closed this issue 2025-12-29 21:25:33 +01:00
Author
Owner

@sysdagenaim commented on GitHub (Jul 29, 2024):

User token as defined in NetBox documentation returns an error : https://netboxlabs.com/docs/netbox/en/stable/administration/permissions/

@sysdagenaim commented on GitHub (Jul 29, 2024): User token as defined in NetBox documentation returns an error : https://netboxlabs.com/docs/netbox/en/stable/administration/permissions/
Author
Owner

@pkeroulas commented on GitHub (Jul 30, 2024):

Our constraint scheme is based on Sites and Tenancy but it is incomplete as some Object Types are independent. User Token would help fill the gap but I confirm the behaviour described in the documentation is broken.

@pkeroulas commented on GitHub (Jul 30, 2024): Our constraint scheme is based on Sites and Tenancy but it is incomplete as some Object Types are independent. User Token would help fill the gap but I confirm the behaviour described in the documentation is broken.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10008