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

Export and Import Custom Fields #7772

Closed
dmetzler1988 opened this issue Nov 8, 2021 · 8 comments
Closed

Export and Import Custom Fields #7772

dmetzler1988 opened this issue Nov 8, 2021 · 8 comments
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@dmetzler1988
Copy link

dmetzler1988 commented Nov 8, 2021

NetBox version

v3.0.9

Python version

3.9

Steps to Reproduce

  1. Create new custom fields with choices (no one exists previously)
  2. Export these custom fields via button Export -> All data
  3. Remove the created custom fields
  4. Import this exported CSV via CSV File Upload
    4.1 An error would occur, that the ID in the first line is not expected.
  5. Open the exported CSV in a text-editor, remove ID in header and on the lines
    5.1 Modify title names to these which are given/listed on import page (all to lowercase, replace spaces with underscore)
    # from
    ID,Name,Content types,Label,Type,Required,Weight,Default,Description,Filter logic,Choices
    # to
    name,content_types,label,type,required,weight,default,description,filter_logic,choices
    
  6. Import this via CSV Data input field and click on Submit

Expected Behavior

The Custom fields will be imported without an error - in an optimal world without a need to modify the exported data.

Observed Behavior

On step 4 this error occurs (as a red popup):

Unexpected column header "ID" found.

If we only remove the ID in header and body, this error occurs at next (as a red popup)

Unexpected column header "Name" found.

And so on for each header column name from export.


On step 6 this error occurs via new Server Errorpage:

<class 'ValueError'>

not enough values to unpack (expected 2, got 1)

Python version: 3.9.5
NetBox version: 3.0.9
@dmetzler1988 dmetzler1988 added the type: bug A confirmed report of unexpected behavior in the application label Nov 8, 2021
@jeremystretch
Copy link
Member

  1. Modify title names to these which are given/listed on import page (all to lowercase, replace spaces with underscore)

I'm afraid this is not sufficient detail for a bug report. Please update your post above to include the exact data being used to reproduce the bug.

@jeremystretch jeremystretch added the status: revisions needed This issue requires additional information to be actionable label Nov 8, 2021
@dmetzler1988
Copy link
Author

dmetzler1988 commented Nov 8, 2021

ok, added some testdata.

Exported file from Netbox
netbox_custom fields.csv

Modified header column for manual import via input field - content is the same than from export - without ID on first position

name,content_types,label,type,required,weight,default,description,filter_logic,choices
test1,"IPAM &gt; IP address, IPAM &gt; prefix, IPAM &gt; VRF",Test One,Text,True,100,,,Loose,[]
test_two,"DCIM &gt; device, IPAM &gt; IP address, IPAM &gt; prefix, IPAM &gt; VRF",Test Two,Selection,True,100,,,Loose,"['choice1', 'choice2', 'third choice', 'last choice']"

edit

i can also reproduce this case on https://demo.netbox.dev
tried it there with a simple import:

name,content_types,label,type,required,weight,default,description,filter_logic,choices
cust_id,Tenancy &gt; tenant,Customer ID,Text,False,100,,,Exact,[]

@jeremystretch
Copy link
Member

The values you've provided for the content types are invalid. The export format uses human-friendly names (e.g. "DCIM > Site"), whereas the import format expects the "dotted" notation (e.g. dcim.site).

@dmetzler1988
Copy link
Author

Ok, that means we need to modify the complete export from System A if we would like to import on System B. This would therefore mean a huge effort for such a simple usecase.

But if that's the way it's planned, so be it.

Do you have a reference-docu for the import style, so that we can check the differences?
Do you maybe have another solution, to export custom-fields from system A to system B (without datas or anything else)?

@jeremystretch
Copy link
Member

Do you have a reference-docu for the import style, so that we can check the differences?

There's a complete reference right on the import page.

Do you maybe have another solution, to export custom-fields from system A to system B (without datas or anything else)?

You can very easily craft a custom export template to export custom fields in whatever format you'd like.

@dmetzler1988
Copy link
Author

dmetzler1988 commented Nov 10, 2021

There's a complete reference right on the import page.

Yes, but the information for dot-notation is missing - i only see a info-popup with numbers as reference for the paths - like 73 for tenancy | tenant. But the numbers also won't work for imports.

You can very easily craft a custom export template to export custom fields in whatever format you'd like.

But this expect to be a template for a page to export datas - not the custom fields settings. I can't choose extras/custom-fields as content-type for the custom export template.
Maybe my definition was not clear enough or we may have a misunderstanding - i would like to export the custom fields settings on /extras/custom-fields, not the content in the custom fields.

@jeremystretch
Copy link
Member

Yes, but the information for dot-notation is missing - i only see a info-popup with numbers as reference for the paths - like 73 for tenancy | tenant.

Ok, that's a bug. It should be listing the dotted formats for these choices. I've opened #7808.

I can't choose extras/custom-fields as content-type for the custom export template.

Looks like that's actually another bug. Looks like we missed adding export template support when custom fields (and other models) were moved from the admin UI to the main UI in v3.0. I've opened #7809 for this one.

Separate from the bugs above, I suppose what we could do is just change the "DCIM > Site" format to "dcim.site". It's not quite as clean, but having one consistent expression for each content type probably yields a better return.

@jeremystretch jeremystretch added status: under review Further discussion is needed to determine this issue's scope and/or implementation and removed status: revisions needed This issue requires additional information to be actionable labels Nov 11, 2021
@jeremystretch
Copy link
Member

I suppose what we could do is just change the "DCIM > Site" format to "dcim.site".

I've opened #7858 to address this application-wide.

@jeremystretch jeremystretch removed the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Nov 17, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants