Misleading Error Message and Logging Issue in Bulk Import
Deployment Type
Self-hosted
NetBox Version
v4.2.9
Python Version
3.12
Steps to Reproduce
- Attempt to import a CSV file with duplicate entries (with the same ID) for DCIM Devices.
- Observe the error message displayed in the UI.
- Check the logs with DEBUG logging disabled.
Expected Behavior
- The error message should accurately reflect the cause of the error, indicating that there are duplicate entries in the CSV file.
- The error should be logged even when DEBUG logging is disabled, to ensure proper tracking and diagnosis.
Observed Behavior
We encountered an issue related to the Operation failed due to object-level permissions violation error message during a bulk import operation. There are a couple of problems that I would like to report:
- Misleading Error Message: The error message Operation failed due to object-level permissions violation is misleading. The error occurs because of a check to verify that the number of objects intended to be updated matches the number updated in the database. This error is raised if any of the items in the CSV file to be imported are repeated. The actual issue is related to duplicate entries in the CSV file, not object-level permissions.
- Logging Issue: Errors like this are only logged if DEBUG logging is enabled. Otherwise, they only appear momentarily in the UI. This results in no record of the error in the logs, as we typically log error-level messages in production. This makes it difficult to track and diagnose such issues.
This line seems to be the issue: https://github.com/netbox-community/netbox/blob/e5cdd8f2b0273ad3a109b6a88a4d87028660dd53/netbox/netbox/views/generic/bulk_views.py#L506
@moises-perez-tfs, thank you for reporting this issue with bulk import error messaging. This appears to be a legitimate concern about misleading error messages and logging behavior.
To properly reproduce and verify the issue, we need CSV content that triggers this behavior. Please provide a minimal CSV file with the specific field names and duplicate entries.
Hey @jnovinger, the file content doesn't need to be too complex. You can use an existing ID and assign it a role name to replace.
id,role
34808,Switch (Access)
34808,Switch (Access)
You can replace 34808 for an existing device ID in your Netbox instance.
This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.