netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Address warnings from generation of OpenAPI schema

Open jeremystretch opened this issue 2 months ago • 4 comments

Proposed Changes

After upgrading to drf-spectacular v0.29.0, generating the OpenAPI schema now yields several hundred warnings similar to those below:

netbox/netbox/wireless/filtersets.py:90: Warning [WirelessLinkViewSet > WirelessLinkFilterSet]: Unable to guess choice types from values, filter method's type hint or find "tag" in model. Defaulting to string.
netbox/netbox/wireless/filtersets.py:90: Warning [WirelessLinkViewSet > WirelessLinkFilterSet]: Unable to guess choice types from values, filter method's type hint or find "tag_id" in model. Defaulting to string.
netbox/netbox/wireless/filtersets.py:90: Warning [WirelessLinkViewSet > WirelessLinkFilterSet]: Unable to guess choice types from values, filter method's type hint or find "tenant" in model. Defaulting to string.
netbox/netbox/wireless/filtersets.py:90: Warning [WirelessLinkViewSet > WirelessLinkFilterSet]: Unable to guess choice types from values, filter method's type hint or find "tag__n" in model. Defaulting to string.
netbox/netbox/wireless/filtersets.py:90: Warning [WirelessLinkViewSet > WirelessLinkFilterSet]: Unable to guess choice types from values, filter method's type hint or find "tag_id__n" in model. Defaulting to string.
netbox/netbox/wireless/filtersets.py:90: Warning [WirelessLinkViewSet > WirelessLinkFilterSet]: Unable to guess choice types from values, filter method's type hint or find "tenant__n" in model. Defaulting to string.

Justification

These warnings likely indicate that the generated schema may not be accurate.

jeremystretch avatar Nov 11 '25 14:11 jeremystretch

I am also getting a lot of warnings for netbox v4.4.7.

opt/netbox/netbox/dcim/filtersets.py: Warning [FrontPortViewSet > FrontPortFilterSet]: Unable to guess choice types from values, filter method's type hint or find "tag" in model. Defaulting to string.
/opt/netbox/netbox/dcim/filtersets.py: Warning [FrontPortViewSet > FrontPortFilterSet]: Unable to guess choice types from values, filter method's type hint or find "tag_id" in model. Defaulting to string.
/opt/netbox/netbox/dcim/filtersets.py: Warning [FrontPortViewSet > FrontPortFilterSet]: Unable to guess choice types from values, filter method's type hint or find "site__n" in model. Defaulting to string.
/opt/netbox/netbox/dcim/filtersets.py: Warning [FrontPortViewSet > FrontPortFilterSet]: Unable to guess choice types from values, filter method's type hint or find "location__n" in model. Defaulting to string.
/opt/netbox/netbox/dcim/filtersets.py: Warning [FrontPortViewSet > FrontPortFilterSet]: Unable to guess choice types from values, filter method's type hint or find "rack__n" in model. Defaulting to string.
/opt/netbox/netbox/dcim/filtersets.py: Warning [FrontPortViewSet > FrontPortFilterSet]: Unable to guess choice types from values, filter method's type hint or find "device__n" in model. Defaulting to string.
/opt/netbox/netbox/dcim/filtersets.py: Warning [FrontPortViewSet > FrontPortFilterSet]: Unable to guess choice types from values, filter method's type hint or find "device_type__n" in model. Defaulting to string

Eventually, the server (k8s pod) stops responding and throws 503.

Sachin-G07 avatar Dec 09 '25 16:12 Sachin-G07

I'm also seeing the same

cjreyn avatar Dec 09 '25 17:12 cjreyn

We're also getting affected by this issue.

mkurjanski avatar Dec 15 '25 14:12 mkurjanski

@cjreyn @mkurjanski this issue is open for volunteers.

jeremystretch avatar Dec 15 '25 15:12 jeremystretch

Looks to be related to this: https://github.com/tfranzel/drf-spectacular/issues/1475

tom0010 avatar Dec 18 '25 08:12 tom0010