Skip to content

Commit 9772c57

Browse files
Merge branch 'develop' into 7113-fix-prefix-iprange-bulkedit
2 parents 6f66b27 + d2fe59a commit 9772c57

File tree

5 files changed

+8
-14
lines changed

5 files changed

+8
-14
lines changed

docs/release-notes/version-3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* [#7101](https://github.com/netbox-community/netbox/issues/7101) - Enforce `MAX_PAGE_SIZE` for table and REST API pagination
2424
* [#7106](https://github.com/netbox-community/netbox/issues/7106) - Fix incorrect "Map It" button URL on a site's Physical Address field
2525
* [#7107](https://github.com/netbox-community/netbox/issues/7107) - Fix missing search button and search results in IP Address assignment "Assign IP" tab
26+
* [#7109](https://github.com/netbox-community/netbox/issues/7109) - Ensure human readability of exceptions raised during REST API requests
2627
* [#7113](https://github.com/netbox-community/netbox/issues/7113) - Fix IPRange bulk options within Prefix view
2728

2829
---

netbox/netbox/middleware.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ def __call__(self, request):
113113

114114
def process_exception(self, request, exception):
115115

116+
# Handle exceptions that occur from REST API requests
117+
if is_api_request(request):
118+
return rest_api_server_error(request)
119+
116120
# Don't catch exceptions when in debug mode
117121
if settings.DEBUG:
118122
return
@@ -121,10 +125,6 @@ def process_exception(self, request, exception):
121125
if isinstance(exception, Http404):
122126
return
123127

124-
# Handle exceptions that occur from REST API requests
125-
if is_api_request(request):
126-
return rest_api_server_error(request)
127-
128128
# Determine the type of exception. If it's a common issue, return a custom error page with instructions.
129129
custom_template = None
130130
if isinstance(exception, ProgrammingError):

netbox/templates/base/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<html
66
lang="en"
77
data-netbox-path="{{ request.path }}"
8-
data-netbox-base-path="{% base_path %}"
8+
data-netbox-base-path="{{ settings.BASE_PATH }}"
99
{% if preferences|get_key:'ui.colormode' == 'dark'%}
1010
data-netbox-color-mode="dark"
1111
{% else %}

netbox/utilities/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def is_api_request(request):
4848
Return True of the request is being made via the REST API.
4949
"""
5050
api_path = reverse('api-root')
51-
return request.path_info.startswith(api_path)
51+
52+
return request.path_info.startswith(api_path) and request.content_type == 'application/json'
5253

5354

5455
def get_view_name(view, suffix=None):

netbox/utilities/templatetags/helpers.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,6 @@ def querystring(request, **kwargs):
355355
return ''
356356

357357

358-
@register.simple_tag()
359-
def base_path():
360-
"""
361-
Access `BASE_PATH` in templates.
362-
"""
363-
return settings.BASE_PATH
364-
365-
366358
@register.inclusion_tag('utilities/templatetags/utilization_graph.html')
367359
def utilization_graph(utilization, warning_threshold=75, danger_threshold=90):
368360
"""

0 commit comments

Comments
 (0)