From 13db4f728cfa9977e1e94e3645e16a177a279188 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 6 Aug 2025 15:03:38 -0400 Subject: [PATCH] Fixes #19988: has_feature() should gracefully handle invalid ContentTypes --- netbox/netbox/models/features.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/netbox/netbox/models/features.py b/netbox/netbox/models/features.py index 2f0e63f7f..1e0ad1229 100644 --- a/netbox/netbox/models/features.py +++ b/netbox/netbox/models/features.py @@ -679,10 +679,14 @@ def has_feature(model_or_ct, feature): ot = model_or_ct # If a ContentType was passed, resolve its model class elif type(model_or_ct) is ContentType: - ot = ObjectType.objects.get_for_model(model_or_ct.model_class()) + model_class = model_or_ct.model_class() + ot = ObjectType.objects.get_for_model(model_class) if model_class else None # For anything else, look up the ObjectType else: ot = ObjectType.objects.get_for_model(model_or_ct) + # ObjectType is invalid/deleted + if ot is None: + return False return feature in ot.features