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

Command errors out with ObjectNotFound exception #2

Closed
glennmatthews opened this issue Mar 3, 2021 · 1 comment · Fixed by #6
Closed

Command errors out with ObjectNotFound exception #2

glennmatthews opened this issue Mar 3, 2021 · 1 comment · Fixed by #6
Assignees
Labels
bug Something isn't working

Comments

@glennmatthews
Copy link
Contributor

Environment

  • Python version: 3.7
  • Nautobot version: 1.0.0b1
  • nautobot-netbox-importer version: 1.0.0

Expected Behavior

Import should run to completion successfully.

Observed Behavior

Traceback (most recent call last):
  File "/usr/local/bin/nautobot-server", line 5, in <module>
    main()
  File "/opt/nautobot/nautobot/core/cli.py", line 62, in main
    initializer=_configure_settings,  # Called after defaults
  File "/opt/nautobot/nautobot/core/runner/runner.py", line 268, in run_app
    management.execute_from_command_line([runner_name, command] + command_args)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/nautobot_netbox_importer/management/commands/import_netbox_json.py", line 91, in handle
    target.sync_from(source, flags=DiffSyncFlags.SKIP_UNMATCHED_DST)
  File "/usr/local/lib/python3.7/site-packages/nautobot_netbox_importer/diffsync/adapters/abstract.py", line 299, in sync_from
    return super().sync_from(source, diff_class=diff_class, flags=flags)
  File "/usr/local/lib/python3.7/site-packages/diffsync/__init__.py", line 464, in sync_from
    result = syncer.perform_sync()
  File "/usr/local/lib/python3.7/site-packages/diffsync/helpers.py", line 251, in perform_sync
    changed |= self.sync_diff_element(element)
  File "/usr/local/lib/python3.7/site-packages/diffsync/helpers.py", line 283, in sync_diff_element
    changed, modified_model = self.sync_model(model, ids, attrs)
  File "/usr/local/lib/python3.7/site-packages/diffsync/helpers.py", line 329, in sync_model
    model = self.model_class.create(diffsync=self.dst_diffsync, ids=ids, attrs=attrs)
  File "/usr/local/lib/python3.7/site-packages/nautobot_netbox_importer/diffsync/models/abstract.py", line 192, in create
    diffsync_ids, nautobot_ids = cls.clean_ids(diffsync, ids)
  File "/usr/local/lib/python3.7/site-packages/nautobot_netbox_importer/diffsync/models/abstract.py", line 168, in clean_ids
    return cls.clean_ids_or_attrs(diffsync, ids)
  File "/usr/local/lib/python3.7/site-packages/nautobot_netbox_importer/diffsync/models/abstract.py", line 114, in clean_ids_or_attrs
    target_record = diffsync.get(target_class, diffsync_value)
  File "/usr/local/lib/python3.7/site-packages/diffsync/__init__.py", line 567, in get
    raise ObjectNotFound(f"{modelname} {uid} not present in {self.name}")
diffsync.exceptions.ObjectNotFound: interface {'site': {'name': 'some site'}, 'tenant': None, 'name': 'some device'}__mgmt0 not present in          NautobotDiffSync

Steps to Reproduce

Details of the data being imported are unavailable at this time.

@glennmatthews glennmatthews added the bug Something isn't working label Mar 3, 2021
@glennmatthews glennmatthews self-assigned this Mar 3, 2021
@glennmatthews glennmatthews changed the title Abort with ObjectNotFound exception Command errors out with ObjectNotFound exception Mar 3, 2021
@glennmatthews
Copy link
Contributor Author

Missing error handling in the GenericForeignKey case; error handling for ObjectNotFound is already present in handling ordinary ForeignKey fields (as well as one-to-one, one-to-many, and many-to-many fields). Will add appropriate logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant