peteeckel / netbox-plugin-dns

NetBox DNS is a NetBox plugin for managing DNS data.
https://pypi.org/project/netbox-plugin-dns
MIT License
194 stars 17 forks source link

Require the view field in the bulk (CSV) import to avoid the importer failing the import #453

Open netravnen opened 2 hours ago

netravnen commented 2 hours ago

Versions NetBox Version: 4.1.4 NetBox DNS Version: 1.1.4 Python Version: 3.11 (Debian Bookworm Stable)

Describe the bug The bulk (CSV) importer will fail the import if the view column is omitted.

To Reproduce Steps to reproduce the behavior:

  1. Go to the record importer
  2. Navigate to the data importer
  3. import data with only the columns of "zone,name,type,value,status"
  4. See error

Expected result

The importer fails the task when using the headers of "zone,name,type,value,status". But works when providing the columns of "view,zone,name,type,value,status"

Actual result

The listed required columns are "name,name,type,value". The importer will fail, if the view column is omitted with the message "object not found".

Code Examples

(Requires the view to exist prior to import, view_name is case-sensitive)

zone,name,type,value
example.com,test1,CNAME,test.othersubdomain.example.comg
view,zone,name,type,value
Test,example.com,test1,CNAME,test.othersubdomain.example.comg
netravnen commented 2 hours ago

Looked around in the code-base. Was unable to locate the function/code-block needed to be edited to require the view field in the bulk importer.

peteeckel commented 2 hours ago

It's not really necessary ...

We can apply the following logic:

I did that recently for a different (as of yet non-public) plugin.

Requiring view generally ist clumsy as it enforces using it for importing even if the environment does not have any non-default views.

netravnen commented 2 hours ago
  • Zone names are unique -> no view needed.

I did try that. Even if the zone-name is unique (within my installation). The bulk (CSV) importer will fail the import task with error "no object found "

netravnen commented 2 hours ago

Another example I tried.

zone,name,type,value
zt,test1,CNAME,test.example.com

Sidenote: .zt is used by the ZeroTier VPN solution. Not relevant for the overall discussion. Just a note if anybody asks.

netravnen commented 2 hours ago

Requiring view generally ist clumsy as it enforces using it for importing even if the environment does not have any non-default views.

It is indeed clumsy. I do not disagree. On the other hand. It makes the use of the bulk importer painful. As the error msg presented (by Netbox) is misleading, IMHO.

peteeckel commented 2 hours ago

I believe you that you tried ... that's why it's a bug :-)

peteeckel commented 1 hour ago

I can import the example you provided without a view and without any problem:

zone,name,type,value
example.com,test1,CNAME,test.othersubdomain.example.comg

What error are you seeing?

(when you define a CNAME, never forget the dot at the end of the value!)

peteeckel commented 1 hour ago
zone,name,type,value
zt,test1,CNAME,test.example.com

works as well after adding the zone zt.

peteeckel commented 1 hour ago

I think now I could reproduce it:

  1. Define a zone zt in view internal
  2. Define the same zone in view external(the view and zone names don't matter as long as the views are not default and the zone names are identical)
  3. Now try to import
    zone,name,type,value
    zt,test1,CNAME,test.example.com

Resulting error message: "Record 1 zone: Object not found: zt"

Is this correct?

peteeckel commented 1 hour ago

Bottom line:

  1. If you don't specify a view, the default view is assumed
  2. If you're not working with the default view you need to specify the view name
  3. The error message is ... well, it could be better. But if you can confirm the above, there is no bug.