[PR #18395] [MERGED] Fixes: #18336 - Perform Rack object validation of u_height and starting_unit on rack_type if present #15341

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/18395
Author: @bctiemann
Created: 1/14/2025
Status: Merged
Merged: 1/17/2025
Merged by: @jeremystretch

Base: mainHead: 18336-validate-rack-height-and-starting-unit


📝 Commits (2)

  • 7a9a684 Perform Rack object validation of u_height and starting_unit on rack_type if present
  • 37a3d33 Calculate effective values before doing validation

📊 Changes

1 file changed (+11 additions, -6 deletions)

View changed files

📝 netbox/dcim/models/racks.py (+11 -6)

📄 Description

Fixes: #18336

Current model validation in Rack.clean() examines the u_height and starting_unit fields but only considers the fields on the Rack itself, not on the RackType if assigned, in which those fields' values override those on the Rack. This can lead to a situation where a Rack with assigned devices above a certain elevation can be assigned to a RackType incompatible with those elevations, because the validation misses the effective u_height and starting_unit of the requested RackType. Subsequent errors occur in SVG rendering and RackForm validation.

This situation is prevented with this change, which ensures that these two fields are validated with consideration of both Rack and RackType values, and assigns the resulting ValidationError to the appropriate form field depending on whether a RackType has been selected or not.


🔄 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/18395 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 1/14/2025 **Status:** ✅ Merged **Merged:** 1/17/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `main` ← **Head:** `18336-validate-rack-height-and-starting-unit` --- ### 📝 Commits (2) - [`7a9a684`](https://github.com/netbox-community/netbox/commit/7a9a684ece8758a3b642e1cb5a45255547007517) Perform Rack object validation of u_height and starting_unit on rack_type if present - [`37a3d33`](https://github.com/netbox-community/netbox/commit/37a3d3388cfd9e0cb7ed5524c2d2999236abb8e2) Calculate effective values before doing validation ### 📊 Changes **1 file changed** (+11 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/models/racks.py` (+11 -6) </details> ### 📄 Description ### Fixes: #18336 Current model validation in `Rack.clean()` examines the `u_height` and `starting_unit` fields but only considers the fields on the Rack itself, not on the RackType if assigned, in which those fields' values override those on the Rack. This can lead to a situation where a Rack with assigned devices above a certain elevation can be assigned to a RackType incompatible with those elevations, because the validation misses the effective `u_height` and `starting_unit` of the requested RackType. Subsequent errors occur in SVG rendering and `RackForm` validation. This situation is prevented with this change, which ensures that these two fields are validated with consideration of both Rack and RackType values, and assigns the resulting `ValidationError` to the appropriate form field depending on whether a RackType has been selected or not. --- <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:21:23 +01:00
adam closed this issue 2025-12-30 00:21:23 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15341