Skip to content

Minor DRF traceback #9878

@ryanmerolle

Description

@ryanmerolle

NetBox version

v3.2.7

Python version

3.10

Steps to Reproduce

  1. Setup a fresh install of NetBox
  2. Setup logging to debug (may not be required)
  3. Open Django Swagger page
  4. Observe below error in the logs:
default for PrimaryKeyRelatedField(allow_null=True, default=CurrentUserDefault(), queryset=<QuerySet [<User: admin>]>, required=False) is callable but it raised an exception when called; 'default' will not be set on schema
Traceback (most recent call last):
File "/opt/netbox/venv/lib/python3.10/site-packages/drf_yasg/utils.py", line 487, in get_field_default
default = default(field)
File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/fields.py", line 290, in __call__
return serializer_field.context['request'].user
KeyError: 'request'
172.24.0.1 - - [28/Jul/2022:16:54:33 +0000] "GET /api/docs/?format=openapi HTTP/1.1" 200 1074260 "http://localhost:8000/api/docs/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"

Expected Behavior

No Error

Observed Behavior

Nothing major, just noise in the logs and possibly a delay in loading the swagger page.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions