[PR #13326] [MERGED] Fixes #12639 - Make sure name expansions throws a validation error on decrementing ranges #14154

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/13326
Author: @kkthxbye-code
Created: 7/31/2023
Status: Merged
Merged: 8/11/2023
Merged by: @jeremystretch

Base: developHead: 12639-fix-expandable-name


📝 Commits (3)

  • d47dd7a Fixes #12639 - Make sure name expansions throws a validation error on decrementing ranges
  • ab0df4b Fix pep8
  • 9972ed7 Also fail on equal start & end values

📊 Changes

3 files changed (+14 additions, -3 deletions)

View changed files

📝 netbox/dcim/forms/object_create.py (+4 -1)
📝 netbox/utilities/forms/utils.py (+7 -0)
📝 netbox/utilities/tests/test_forms.py (+3 -2)

📄 Description

Fixes: #12639

The code is a tiny bit messy, but I did my best.

Changes:

  • parse_alphanumeric_range now throws a ValidationError when its passed decrementing ranges.
  • The ComponentCreateForm clean method has been slightly reworked to bail out if the name field is not in cleaned_data. Not quite sure what is going on, but I think it's because validation continues even if the above ValidationError is thrown.
  • The tests has been changed to expect an Exception instead of an empty list on decrementing ranges.

Tests passes now, but please give it a test to make sure I didn't mess anything up. The logic for expandable fields is a little hard to grok.


🔄 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/13326 **Author:** [@kkthxbye-code](https://github.com/kkthxbye-code) **Created:** 7/31/2023 **Status:** ✅ Merged **Merged:** 8/11/2023 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `12639-fix-expandable-name` --- ### 📝 Commits (3) - [`d47dd7a`](https://github.com/netbox-community/netbox/commit/d47dd7a1275e1aa01dca1dafbd81b28268779818) Fixes #12639 - Make sure name expansions throws a validation error on decrementing ranges - [`ab0df4b`](https://github.com/netbox-community/netbox/commit/ab0df4bbae3821770e58a66e3dfe62300bcdc688) Fix pep8 - [`9972ed7`](https://github.com/netbox-community/netbox/commit/9972ed7cfa86a6771261f9b60cc4913f711f6788) Also fail on equal start & end values ### 📊 Changes **3 files changed** (+14 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/forms/object_create.py` (+4 -1) 📝 `netbox/utilities/forms/utils.py` (+7 -0) 📝 `netbox/utilities/tests/test_forms.py` (+3 -2) </details> ### 📄 Description ### Fixes: #12639 The code is a tiny bit messy, but I did my best. Changes: * `parse_alphanumeric_range` now throws a `ValidationError` when its passed decrementing ranges. * The `ComponentCreateForm` clean method has been slightly reworked to bail out if the name field is not in cleaned_data. Not quite sure what is going on, but I think it's because validation continues even if the above ValidationError is thrown. * The tests has been changed to expect an Exception instead of an empty list on decrementing ranges. Tests passes now, but please give it a test to make sure I didn't mess anything up. The logic for expandable fields is a little hard to grok. --- <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:22:53 +01:00
adam closed this issue 2025-12-29 23:22:53 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14154