[PR #20717] [MERGED] Fixes: #20670: Related Object Validation #16030

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20717
Author: @m-hau
Created: 10/30/2025
Status: Merged
Merged: 11/6/2025
Merged by: @bctiemann

Base: mainHead: bugfix/related-object-validation


📝 Commits (5)

  • 8a59fc7 Fix related object index
  • 8452222 Fix record index for related objects
  • 78223ce Validate related object field is list
  • 1245a9f Validate related object is dictionary
  • fbe76ac Fix non-existent-id error message

📊 Changes

17 files changed (+182 additions, -36 deletions)

View changed files

📝 netbox/dcim/tests/test_views.py (+125 -0)
📝 netbox/netbox/views/generic/bulk_views.py (+28 -7)
📝 netbox/translations/cs/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/da/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/de/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/en/LC_MESSAGES/django.po (+1 -1)
📝 netbox/translations/es/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/fr/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/it/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/ja/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/nl/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/pl/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/pt/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/ru/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/tr/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/uk/LC_MESSAGES/django.po (+2 -2)
📝 netbox/translations/zh/LC_MESSAGES/django.po (+2 -2)

📄 Description

Fixes: #20670

Explicitly check that any related object field is a list, and that each related object is a dictionary, and trigger a validation error if this is not the case. This prevents these cases to result in a hard internal error to occur.

While testing I also found three other minor issues in the same code area, which I took the liberty to fix as well:

  • Related objects are no longer indexed by 0 in the validation errors, but now from 1 like the top-level objects ("records")
  • Related object validation errors now show the correct top-level object ("record") index
  • Change the "Object with ID x does not exist" error to use the same format and channel as all other validation errors

Please see the individual commit messages for more detailed information on each individual change.


🔄 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/20717 **Author:** [@m-hau](https://github.com/m-hau) **Created:** 10/30/2025 **Status:** ✅ Merged **Merged:** 11/6/2025 **Merged by:** [@bctiemann](https://github.com/bctiemann) **Base:** `main` ← **Head:** `bugfix/related-object-validation` --- ### 📝 Commits (5) - [`8a59fc7`](https://github.com/netbox-community/netbox/commit/8a59fc733c17ceac6356b944beb9aa917f775116) Fix related object index - [`8452222`](https://github.com/netbox-community/netbox/commit/8452222761800ee6c1d9f2dc4db98795f16ecaaa) Fix record index for related objects - [`78223ce`](https://github.com/netbox-community/netbox/commit/78223cea03c93bb190042b280300cd5403b06b71) Validate related object field is list - [`1245a9f`](https://github.com/netbox-community/netbox/commit/1245a9f99db4b29359306567429ffe0ad38cba02) Validate related object is dictionary - [`fbe76ac`](https://github.com/netbox-community/netbox/commit/fbe76ac98aa2d58421dcb64cfe1a2898b4c50ad6) Fix non-existent-id error message ### 📊 Changes **17 files changed** (+182 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/tests/test_views.py` (+125 -0) 📝 `netbox/netbox/views/generic/bulk_views.py` (+28 -7) 📝 `netbox/translations/cs/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/da/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/de/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/en/LC_MESSAGES/django.po` (+1 -1) 📝 `netbox/translations/es/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/fr/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/it/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/ja/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/nl/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/pl/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/pt/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/ru/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/tr/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/uk/LC_MESSAGES/django.po` (+2 -2) 📝 `netbox/translations/zh/LC_MESSAGES/django.po` (+2 -2) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #20670 Explicitly check that any related object field is a list, and that each related object is a dictionary, and trigger a validation error if this is not the case. This prevents these cases to result in a hard internal error to occur. While testing I also found three other minor issues in the same code area, which I took the liberty to fix as well: - Related objects are no longer indexed by 0 in the validation errors, but now from 1 like the top-level objects ("records") - Related object validation errors now show the correct top-level object ("record") index - Change the "Object with ID x does not exist" error to use the same format and channel as all other validation errors Please see the individual commit messages for more detailed information on each individual change. --- <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:25:24 +01:00
adam closed this issue 2025-12-30 00:25:24 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#16030