nautobot / nautobot-app-version-control

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

Plugin Crashes under Nautobot Next #132

Closed nniehoff closed 2 years ago

nniehoff commented 2 years ago

When building a container based on the next branch of Nautobot (1.2.0) the plugin crashes under some basic usecases. Create a branch, make a change, then attempt either a PR or a diff... I have seen 2 stack traces under various circumstances:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 178, in get_model
    return self.models[model_name.lower()]
KeyError: 'diff_site'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/dolt/dynamic/diff_factory.py", line 29, in get_model
    return apps.get_model("dolt", self.model_name)
  File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 211, in get_model
    return app_config.get_model(model_name, require_ready=require_ready)
  File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 181, in get_model
    "App '%s' doesn't have a '%s' model." % (self.label, model_name))
LookupError: App 'dolt' doesn't have a 'diff_site' model.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 171, in _get_response
    response = middleware_method(request, callback, callback_args, callback_kwargs)
  File "/usr/local/lib/python3.6/site-packages/dolt/middleware.py", line 74, in process_view
    return view_func(request, *view_args, **view_kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/nautobot/utilities/views.py", line 94, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/nautobot/core/views/generic.py", line 123, in get
    **self.get_extra_context(request, instance),
  File "/usr/local/lib/python3.6/site-packages/dolt/views.py", line 45, in get_extra_context
    return {"results": diffs.two_dot_diffs(from_commit=merge_base, to_commit=head)}
  File "/usr/local/lib/python3.6/site-packages/dolt/diffs.py", line 43, in two_dot_diffs
    diffs = factory.get_model().objects.filter(from_commit=from_commit, to_commit=to_commit)
  File "/usr/local/lib/python3.6/site-packages/dolt/dynamic/diff_factory.py", line 31, in get_model
    return self.make_model()
  File "/usr/local/lib/python3.6/site-packages/dolt/dynamic/diff_factory.py", line 40, in make_model
    **self._make_diff_fields(),
  File "/usr/local/lib/python3.6/site-packages/dolt/dynamic/diff_factory.py", line 88, in _make_diff_fields
    diff_fields.extend(self._diff_fields_from_field(field))
  File "/usr/local/lib/python3.6/site-packages/dolt/dynamic/diff_factory.py", line 103, in _diff_fields_from_field
    return [clone_field(pre) for pre in ("to_", "from_")]
  File "/usr/local/lib/python3.6/site-packages/dolt/dynamic/diff_factory.py", line 103, in <listcomp>
    return [clone_field(pre) for pre in ("to_", "from_")]
  File "/usr/local/lib/python3.6/site-packages/dolt/dynamic/diff_factory.py", line 101, in clone_field
    return field_type(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/nautobot/core/fields.py", line 61, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django_extensions/db/fields/__init__.py", line 155, in __init__
    raise ValueError("missing 'populate_from' argument")
ValueError: missing 'populate_from' argument

and

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/utils/deprecation.py", line 116, in __call__
    response = self.process_response(request, response)
  File "/usr/local/lib/python3.6/site-packages/django/contrib/sessions/middleware.py", line 63, in process_response
    request.session.save()
  File "/usr/local/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py", line 84, in save
    using = router.db_for_write(self.model, instance=obj)
  File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 270, in _route_db
    chosen_db = method(model, **hints)
  File "/usr/local/lib/python3.6/site-packages/dolt/routers.py", line 54, in db_for_write
    <strong>"{DOLT_DEFAULT_BRANCH}"</strong>."""
dolt.utils.DoltError: Error writing model <strong>Session</strong>
                        on branch <strong>"update-status-cdg"</strong>:
                        non-versioned models must be written on branch
                        <strong>"main"</strong>.

The fork in which I attempted Nautobot 1.2 is: https://github.com/nniehoff/nautobot-plugin-workflow-dolt/tree/nn_nautobot_1.2