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

Import of objectpermissions that have constraints consisting of a list of ORed conditions fails #64

Closed
jcsicard opened this issue Jan 19, 2022 · 0 comments · Fixed by #65
Assignees
Labels
bug Something isn't working

Comments

@jcsicard
Copy link

Environment

  • Python version: 3.9
  • Nautobot version: 1.2.2
  • nautobot-netbox-importer version: 1.4.0

Expected Behavior

Import of objectpermissions that have constraints consisting of a list of conditions such as
[{"name": "foo"}, {"name": "bar"}]
should work.

Observed Behavior

objectpermission : 0%| | 0/ 323 [00:00]17:15:54 error Invalid data according to internal data model
12:15:54§ comment: This may be an issue with your source data or may reflect a bug in this plugin.
12:15:54§ action: load
12:15:54§ exception: 1 validation error for ObjectPermission
12:15:54§ constraints
12:15:54§ value is not a valid dict (type=type_error.dict)
12:15:54§ model: objectpermission
12:15:54§ model_data:
12:15:54§ {'actions': '["view"]',
12:15:54§ 'constraints': [{'name': 'foo'}, {'name': 'bar'}],
12:15:54§ 'description': '',
12:15:54§ 'enabled': True,
12:15:54§ 'groups': [{'name': 'foobargrp'}],
12:15:54§ 'name': 'foobarperm',
12:15:54§ 'object_types': [{'app_label': 'tenancy', 'model': 'tenantgroup'},
12:15:54§ {'app_label': 'tenancy', 'model': 'tenant'}],
12:15:54§ 'pk': 308,
12:15:54§ 'users': [UUID('036b093d-d350-538e-bad9-1fd132b1f5fa')]}

The model validation is overly restrictive in allowing only dict type while lists should also be allowed:
https://github.com/nautobot/nautobot-plugin-netbox-importer/blob/a225bc38b9ef51ff8d6f1fdc72dd5472eedf0b30/nautobot_netbox_importer/diffsync/models/users.py#L27

Steps to Reproduce

  1. In netbox, create a permission with the following properties
    object_types: tenancy/tenant, tenancy/tenant group
    constraints: [{"name": "foo"}, {"name": "bar"}]

  2. Export netbox data

  3. Import to nautobot...

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.

2 participants