[PR #3222] [MERGED] Fix error message on trying to delete protected models #12527

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/3222
Author: @hellerve
Created: 5/28/2019
Status: Merged
Merged: 5/29/2019
Merged by: @jeremystretch

Base: developHead: tmp


📝 Commits (2)

  • cc87d99 all: fix error message on trying to delete protected models (references #3211)
  • 2c7bad9 utilities: move protectederror handling to modelviewset

📊 Changes

3 files changed (+35 additions, -2 deletions)

View changed files

📝 netbox/ipam/tests/test_api.py (+18 -0)
📝 netbox/utilities/api.py (+17 -1)
📝 netbox/utilities/middleware.py (+0 -1)

📄 Description

Fixes: #3211

This PR fixes the error returned by Netbox on models.ProtectedError by extending the current error-handling middleware. The middleware returns a message mimicking the other API error messages, because it should only be triggered on API calls (though I’m not 100% sure this invariant holds).

I’m not completely certain this is the right API/UX yet. It certainly feels better than what was there before, but maybe not completely right?

A test case is included.

Cheers


🔄 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/3222 **Author:** [@hellerve](https://github.com/hellerve) **Created:** 5/28/2019 **Status:** ✅ Merged **Merged:** 5/29/2019 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `tmp` --- ### 📝 Commits (2) - [`cc87d99`](https://github.com/netbox-community/netbox/commit/cc87d9901785f252d011f486eb95ecf74898dc1a) all: fix error message on trying to delete protected models (references #3211) - [`2c7bad9`](https://github.com/netbox-community/netbox/commit/2c7bad9fff4b4741f69c68586dbb624757221805) utilities: move protectederror handling to modelviewset ### 📊 Changes **3 files changed** (+35 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `netbox/ipam/tests/test_api.py` (+18 -0) 📝 `netbox/utilities/api.py` (+17 -1) 📝 `netbox/utilities/middleware.py` (+0 -1) </details> ### 📄 Description ### Fixes: #3211 This PR fixes the error returned by Netbox on `models.ProtectedError` by extending the current error-handling middleware. The middleware returns a message mimicking the other API error messages, because it should only be triggered on API calls (though I’m not 100% sure this invariant holds). I’m not completely certain this is the right API/UX yet. It certainly feels better than what was there before, but maybe not completely right? A test case is included. Cheers --- <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 22:22:05 +01:00
adam closed this issue 2025-12-29 22:22:06 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12527