Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nautobot-server loaddata errors for ObjectChange records #3885

Closed
mzbroch opened this issue Jun 9, 2023 · 6 comments
Closed

nautobot-server loaddata errors for ObjectChange records #3885

mzbroch opened this issue Jun 9, 2023 · 6 comments
Assignees
Labels
type: bug Something isn't working as expected
Milestone

Comments

@mzbroch
Copy link
Contributor

mzbroch commented Jun 9, 2023

Environment

  • Nautobot version (Docker tag too if applicable): 34c06ba7a177 (v2.0.0b1)
  • Python version: 3.8
  • Database platform, version:
  • Middleware(s):

Steps to Reproduce

  1. dumpdata as per Nautobot documentation (https://docs.nautobot.com/projects/core/en/v2.0.0-beta.1/administration/nautobot-server/?h=dumpdata#dumpdata)
  2. loaddata as per Nautobot documentation

Expected Behavior

loaddata works

Observed Behavior

loaddata errors :

root@34c06ba7a177:/source# nautobot-server dumpdata --natural-foreign --natural-primary --exclude contenttypes --exclude auth.permission --format json --indent 2 --traceback  > /tmp/nautobot_dump.json
08:17:03.254 DEBUG   nautobot.core.celery __init__.py        import_jobs_as_celery_tasks() :
  Importing system Jobs
08:17:03.449 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job nautobot.core.jobs.GitRepositorySync
08:17:03.455 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job nautobot.core.jobs.GitRepositoryDryRun
08:17:04.736 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleDryRunJob
08:17:04.737 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleJob
08:17:04.737 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleHiddenJob
08:17:04.738 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleLoggingJob
08:17:04.738 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleJobHookReceiver
08:17:04.739 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleSimpleJobButtonReceiver
08:17:04.740 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleComplexJobButtonReceiver
root@34c06ba7a177:/source# nautobot-server loaddata --traceback /tmp/nautobot_dump.json
08:17:26.171 DEBUG   nautobot.core.celery __init__.py        import_jobs_as_celery_tasks() :
  Importing system Jobs
08:17:26.378 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job nautobot.core.jobs.GitRepositorySync
08:17:26.385 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job nautobot.core.jobs.GitRepositoryDryRun
08:17:28.808 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleDryRunJob
08:17:28.809 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleJob
08:17:28.809 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleHiddenJob
08:17:28.810 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleLoggingJob
08:17:28.810 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleJobHookReceiver
08:17:28.811 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleSimpleJobButtonReceiver
08:17:28.812 DEBUG   nautobot.core.celery __init__.py                      register_jobs() :
  Registering job example_plugin.jobs.ExampleComplexJobButtonReceiver
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/core/serializers/json.py", line 70, in Deserializer
    yield from PythonDeserializer(objects, **options)
  File "/usr/local/lib/python3.8/site-packages/django/core/serializers/python.py", line 148, in Deserializer
    obj = base.build_instance(Model, data, using)
  File "/usr/local/lib/python3.8/site-packages/django/core/serializers/base.py", line 263, in build_instance
    natural_key = Model(**data).natural_key()
  File "/source/nautobot/core/models/__init__.py", line 90, in natural_key
    for lookups in [lookup.split("__") for lookup in self.natural_key_field_lookups]:
  File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py", line 61, in __get__
    return self.fget(cls)
  File "/source/nautobot/core/models/__init__.py", line 146, in natural_key_field_lookups
    raise AttributeError(
AttributeError: Unable to identify an intrinsic natural-key definition for ObjectChange. If there isn't at least one UniqueConstraint, unique_together, or field with unique=True, you probably need to explicitly declare the 'natural_key_field_names' for this model, or potentially override the default 'natural_key_field_lookups' implementation for this model.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/nautobot-server", line 6, in <module>
    sys.exit(main())
  File "/source/nautobot/core/cli/__init__.py", line 54, in main
    run_app(
  File "/source/nautobot/core/runner/runner.py", line 263, in run_app
    management.execute_from_command_line([runner_name, command] + command_args)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 78, in handle
    self.loaddata(fixture_labels)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 123, in loaddata
    self.load_label(fixture_label)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 181, in load_label
    for obj in objects:
  File "/usr/local/lib/python3.8/site-packages/django/core/serializers/json.py", line 74, in Deserializer
    raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture '/tmp/nautobot_dump.json':
@bryanculver
Copy link
Member

Are you dumping and loading between different Nautobot versions?

@bryanculver bryanculver added the type: bug Something isn't working as expected label Jun 9, 2023
@bryanculver bryanculver added this to the v2.0.0 milestone Jun 9, 2023
@glennmatthews
Copy link
Contributor

Looks like a miss in #1574, as ObjectChange isn't mentioned in #2907/#2908/#2909. More fuel for us needing to do #3752 though.

@mzbroch
Copy link
Contributor Author

mzbroch commented Jun 9, 2023

Are you dumping and loading between different Nautobot versions?

Both on same container instance from 34c06ba7a177 (v2.0.0b1)

@itdependsnetworks
Copy link
Contributor

If there is such a thing as priority on beta code, this would be one I would vote for. We are using similar constructs for our data generation processes and it is not working, which means it is more difficult to test, and given the amount of changes that is obviously problematic.

@glennmatthews
Copy link
Contributor

It's also worth being aware of #3666 in that case, which may take some time longer to resolve than this specific issue.

@glennmatthews glennmatthews self-assigned this Jun 9, 2023
@glennmatthews glennmatthews changed the title nautobot-server loaddata errors nautobot-server loaddata errors for ObjectChange records Jun 12, 2023
glennmatthews added a commit that referenced this issue Jun 12, 2023
…Change API test, add ObjectChange unique_together (#3896)

* Fix KeyError in nested serialization of ConfigContext, and add API test case for ObjectChanges

* Changelog

* Fix #3885 - add "unique_together" for ObjectChange records

* Loosen unique_together constraint
@glennmatthews
Copy link
Contributor

Resolved by #3896.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

No branches or pull requests

4 participants