[PR #17584] [CLOSED] Fixes: #17498 - Avoid error in bulk import when non-unique identifying values are provided #15135

Closed
opened 2025-12-30 00:20:11 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/17584
Author: @bctiemann
Created: 9/24/2024
Status: Closed

Base: developHead: 17498-catch-MultipleObjectsReturned-in-bulk-import


📝 Commits (1)

  • 50fc15f Extend _clean_fields to catch MultipleObjectsReturned and display a toast with a useful message instead of a 500 error

📊 Changes

1 file changed (+7 additions, -0 deletions)

View changed files

📝 netbox/netbox/forms/base.py (+7 -0)

📄 Description

Fixes: #17498

Extends _clean_fields to catch MultipleObjectsReturned exceptions on any field where an ad-hoc accessor is used (for example manufacturer.description in DeviceType) and multiple matching records are found.

With this change, a toast is displayed which surfaces the model that caused the exception. Because this is a non-field clean method, the field's specific metadata is not available, but the general message from the exception (which contains the model name) is reflected in the toast which should lead the user to a solution.

Note that other extraneous toasts appear as well as a side effect; this is not ideal, but this solution avoids the much greater issue of an opaque 500 error.

Screenshot 2024-09-23 at 8 05 13 PM

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/17584 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 9/24/2024 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `17498-catch-MultipleObjectsReturned-in-bulk-import` --- ### 📝 Commits (1) - [`50fc15f`](https://github.com/netbox-community/netbox/commit/50fc15fadbd7270f2f8e174e17597e4b8f4a2c97) Extend _clean_fields to catch MultipleObjectsReturned and display a toast with a useful message instead of a 500 error ### 📊 Changes **1 file changed** (+7 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `netbox/netbox/forms/base.py` (+7 -0) </details> ### 📄 Description ### Fixes: #17498 Extends `_clean_fields` to catch `MultipleObjectsReturned` exceptions on any field where an ad-hoc accessor is used (for example `manufacturer.description` in `DeviceType`) and multiple matching records are found. With this change, a toast is displayed which surfaces the model that caused the exception. Because this is a non-field clean method, the field's specific metadata is not available, but the general message from the exception (which contains the model name) is reflected in the toast which should lead the user to a solution. Note that other extraneous toasts appear as well as a side effect; this is not ideal, but this solution avoids the much greater issue of an opaque 500 error. <img width="905" alt="Screenshot 2024-09-23 at 8 05 13 PM" src="https://github.com/user-attachments/assets/95c3bbe2-45c0-48ed-8ab6-7445dcf30fad"> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:20:11 +01:00
adam closed this issue 2025-12-30 00:20:11 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15135