[PR #19588] [MERGED] Fixes #19520: restore ability to set Prefix.scope via API #15675

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19588
Author: @jnovinger
Created: 5/27/2025
Status: Merged
Merged: 5/27/2025
Merged by: @arthanson

Base: mainHead: 19520-change-prefix-scope-via-api


📝 Commits (1)

  • d34263c Fixes #19520: restores ability to set Prefix.scope via API

📊 Changes

2 files changed (+14 additions, -1 deletions)

View changed files

📝 netbox/dcim/models/mixins.py (+1 -1)
📝 netbox/ipam/tests/test_api.py (+13 -0)

📄 Description

Fixes: #19520

It turned out that the .prefetch_related('scope') on the PrefixViewSet.queryset attribute was causing scope to not be set on the prefix instance being changed--even though scope_id was set--causing the check in CachedScopeMixin.clean() to fail. I only found this when comparing the behavior of API endpoints for other models that make use of the CachedScopeMixin model mixin.


🔄 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/19588 **Author:** [@jnovinger](https://github.com/jnovinger) **Created:** 5/27/2025 **Status:** ✅ Merged **Merged:** 5/27/2025 **Merged by:** [@arthanson](https://github.com/arthanson) **Base:** `main` ← **Head:** `19520-change-prefix-scope-via-api` --- ### 📝 Commits (1) - [`d34263c`](https://github.com/netbox-community/netbox/commit/d34263c5a02758ae84c5a59aec5b241267acc829) Fixes #19520: restores ability to set Prefix.scope via API ### 📊 Changes **2 files changed** (+14 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/models/mixins.py` (+1 -1) 📝 `netbox/ipam/tests/test_api.py` (+13 -0) </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: #19520 It turned out that the `.prefetch_related('scope')` on the `PrefixViewSet.queryset` attribute was causing `scope` to not be set on the prefix instance being changed--even though `scope_id` _was_ set--causing the check in `CachedScopeMixin.clean()` to fail. I only found this when comparing the behavior of API endpoints for other models that make use of the `CachedScopeMixin` model mixin. <!-- Please include a summary of the proposed changes below. --> --- <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:23:21 +01:00
adam closed this issue 2025-12-30 00:23:21 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15675