Fixes: #19901 - Make module_bay recursion check on Module.clean tolerant of unset module.module_bay #648

Closed
opened 2026-04-05 17:02:16 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @bctiemann on 1/7/2026

Fixes: #19901

In the clean method of Module, we have a recursion check that presumes that the attribute module_bay has been set on the self object. If this attribute is missing, we throw a "Module has no module_bay" error, which is misleading and unhelpful.

This issue manifests when importing a module to a device that has no name, but this seems to be a red herring, as it can also occur on devices with names. It is a side effect of the recursion check not properly handling cases where module.module_bay is unset.

This change fixes the issue by skipping iterations in the recursion check where module.module_bay is unset.

Note that it does not directly address the reported issue in #19901, that an error is thrown when bulk-importing Modules to a Device whose name is null. For these cases, the workaround (and expected usage) is to use device.id as the bulk import field rather than the name; and with this fix a more helpful snackbar validation error is produced instead of an unhandled Server Error:

Screenshot 2026-01-06 at 10 01 53 PM
*Originally created by @bctiemann on 1/7/2026* ### Fixes: #19901 In the `clean` method of `Module`, we have a recursion check that presumes that the attribute `module_bay` has been set on the `self` object. If this attribute is missing, we throw a "Module has no module_bay" error, which is misleading and unhelpful. This issue manifests when importing a module to a device that has no name, but this seems to be a red herring, as it can also occur on devices with names. It is a side effect of the recursion check not properly handling cases where `module.module_bay` is unset. This change fixes the issue by skipping iterations in the recursion check where `module.module_bay` is unset. **Note** that it does not directly address the reported issue in #19901, that an error is thrown when bulk-importing Modules to a Device whose name is null. For these cases, the workaround (and expected usage) is to use `device.id` as the bulk import field rather than the name; and with this fix a more helpful snackbar validation error is produced instead of an unhandled Server Error: <img width="880" height="750" alt="Screenshot 2026-01-06 at 10 01 53 PM" src="https://github.com/user-attachments/assets/7ae539d3-8d24-4140-8c78-5f1b9a8c48cd" />
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#648