[PR #11346] [MERGED] Fixes #11345 - Fix module validation #13775

Closed
opened 2025-12-29 23:20:44 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/11346
Author: @kkthxbye-code
Created: 12/30/2022
Status: Merged
Merged: 1/3/2023
Merged by: @jeremystretch

Base: developHead: 11345-fix-module-validation


📝 Commits (2)

  • 472542b Make sure we bail out if field validation failed when importing modules
  • 1b696f5 Tweak form validation logic

📊 Changes

2 files changed (+6 additions, -5 deletions)

View changed files

📝 netbox/dcim/forms/common.py (+5 -4)
📝 netbox/dcim/models/devices.py (+1 -1)

📄 Description

Fixes: #11345

The issue was that validation of module component replication/adoption was executed even if field validation failed. The model also had a validation step that would throw an exception when no module_bay was set (which was the case when trying to import to a non-existant module bay).

I'm not sure if this is actually the preferred way to do this:

cleaned_data = super().clean()

# Skip form validation if field validation already found errors.
if self.errors:
    return cleaned_data

Please let me know if there is a smarted way to bail out if field validation (non-existant device for example) has already failed.


🔄 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/11346 **Author:** [@kkthxbye-code](https://github.com/kkthxbye-code) **Created:** 12/30/2022 **Status:** ✅ Merged **Merged:** 1/3/2023 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `11345-fix-module-validation` --- ### 📝 Commits (2) - [`472542b`](https://github.com/netbox-community/netbox/commit/472542b888778c60aca412c55ccf41ded44f2914) Make sure we bail out if field validation failed when importing modules - [`1b696f5`](https://github.com/netbox-community/netbox/commit/1b696f58a5c7c6c03d80deb04f4046b9427e264d) Tweak form validation logic ### 📊 Changes **2 files changed** (+6 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/forms/common.py` (+5 -4) 📝 `netbox/dcim/models/devices.py` (+1 -1) </details> ### 📄 Description ### Fixes: #11345 The issue was that validation of module component replication/adoption was executed even if field validation failed. The model also had a validation step that would throw an exception when no module_bay was set (which was the case when trying to import to a non-existant module bay). I'm not sure if this is actually the preferred way to do this: ``` cleaned_data = super().clean() # Skip form validation if field validation already found errors. if self.errors: return cleaned_data ``` Please let me know if there is a smarted way to bail out if field validation (non-existant device for example) has already failed. --- <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-29 23:20:44 +01:00
adam closed this issue 2025-12-29 23:20:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13775