nautobot / nautobot-app-version-control

Version Control App that uses and requires a Dolt Database
Other
30 stars 6 forks source link

Fix #149 - Fix `FieldError` on Nautobot v1.2.x when creating PR review #157

Closed jathanism closed 2 years ago

jathanism commented 2 years ago

I narrowed down the issue to be related to this change in nautobot.core.views.generic.ObjectEditView.get_object():

@@ -248,13 +283,23 @@ class ObjectEditView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View):

     def get_object(self, kwargs):
         # Look up an existing object by slug or PK, if provided.
-        if "slug" in kwargs:
-            return get_object_or_404(self.queryset, slug=kwargs["slug"])
-        elif "pk" in kwargs:
-            return get_object_or_404(self.queryset, pk=kwargs["pk"])
-        # Otherwise, return a new instance.
+        if kwargs:
+            return get_object_or_404(self.queryset, **kwargs)
         return self.queryset.model()

If I revert the method to pre-1.2.0 it works. For now I dropped a FIXME comment in there to revisit this at a later date.

tim-fiola commented 2 years ago

I've tested the fix in this branch and I can now create pull request reviews

tim-fiola commented 2 years ago

image

jathanism commented 2 years ago

I confirmed that https://github.com/nautobot/nautobot/pull/1145 fixes this and obviates the need for this PR.