-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Custom field with trailing white space unable to import #15082
Comments
Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v3.7.1. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data. |
I would be extremely careful about automatically stripping leading and trailing white space in imports. There is already a pretty frustrating bug when importing tab-separated data where the input gets trimmed and it breaks on the last row if it has legitimate trailing tabs for empty columns. I think the expectation should be that data entered during a bulk import has already been adequately cleaned beforehand. |
I'm not sure if the problem was understand correctly. Wgen defining the custom field, one of the possible values has a trailung blank. And it is not possbile to import this value using CSV import. It looks like Netbox already drops the blank on an import and therefore the importvalue doesn't match the custom field value. |
I analyzed the source code a little and I think I found the cause. The csv reader doesn't drop the blank values but Netbox does: And if I understand the code correctly, the CustomFieldChoices are not striped. |
That made it sound like you were saying that the fields should be stripped in the CSV import, not on the custom field choice value. It sounds though like the CSV fields are being stripped, while the custom field choice values are not. So, is this bug actually for the custom field choice values not being stripped? If so, that was extremely unclear from the initial bug report, but it does make sense to me. That being said, I also find it kind of surprising and a bit unintuitive from a UX standpoint that a quoted value in the CSV import would still strip white space. I might understand that if the field was just left raw and unquoted, but maybe that nuance of unquoting is handled by the CSV library and the NetBox code is not able to make that distinction. |
@jeremystretch I verified it with current Netbox version using Docker [v3.7.3-2.8.0]. Steps:
And this happens because Netbox trims import data fields but not field choice values. I'd say trimming import data is incorrect behavior. |
Could you please assign it to me? |
Deployment Type
Self-hosted
NetBox Version
v3.6.9
Python Version
3.8
Steps to Reproduce
This won't work too:
But this works:
Expected Behavior
It will get imported
Suggestion: By default remove any leading and trailing white spaces form field values.
Observed Behavior
Error: "Record 1 cf_CustField: Select a valid choice. bla is not one of the available choices."
The text was updated successfully, but these errors were encountered: