Skip to content

Commit ac488e6

Browse files
authored
fix: bug when CODE_OWNER_MAPPINGS not defined (#464)
No code_owner custom attributes should be added when CODE_OWNER_MAPPINGS is not defined. There was a bug in both the code and the unit tests. This has been fixed.
1 parent f5d9b01 commit ac488e6

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ Change Log
1111

1212
.. There should always be an "Unreleased" section for changes pending release.
1313
14+
7.0.1 - 2024-11-21
15+
------------------
16+
Fixed
17+
~~~~~
18+
* Fix bug where code owner custom attributes were being defined, even when the CODE_OWNER_MAPPINGS setting was not defined.
19+
1420
7.0.0 - 2024-10-16
1521
------------------
1622
Removed

edx_django_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
EdX utilities for Django Application development..
33
"""
44

5-
__version__ = "7.0.0"
5+
__version__ = "7.0.1"
66

77
default_app_config = (
88
"edx_django_utils.apps.EdxDjangoUtilsConfig"

edx_django_utils/monitoring/internal/code_owner/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def get_code_owner_mappings():
8888
# .. setting_description: Used for monitoring and reporting of ownership. Use a
8989
# dict with keys of code owner name and value as a list of dotted path
9090
# module names owned by the code owner.
91-
code_owner_mappings = getattr(settings, 'CODE_OWNER_MAPPINGS', {})
91+
code_owner_mappings = getattr(settings, 'CODE_OWNER_MAPPINGS', None)
92+
if code_owner_mappings is None:
93+
return None
9294

9395
try:
9496
for code_owner in code_owner_mappings:

edx_django_utils/monitoring/tests/code_owner/test_middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ def test_code_owner_transaction_mapping_error(self, mock_newrelic_agent, mock_se
231231
mock_set_custom_attribute, has_path_error=True, has_transaction_error=True
232232
)
233233

234-
@patch('edx_django_utils.monitoring.internal.code_owner.utils.set_custom_attribute')
234+
@patch('edx_django_utils.monitoring.internal.code_owner.middleware.set_custom_attribute')
235235
def test_code_owner_no_mappings(self, mock_set_custom_attribute):
236236
request = RequestFactory().get('/test/')
237237
self.middleware(request)
238238
mock_set_custom_attribute.assert_not_called()
239239

240-
@patch('edx_django_utils.monitoring.internal.code_owner.utils.set_custom_attribute')
240+
@patch('edx_django_utils.monitoring.internal.code_owner.middleware.set_custom_attribute')
241241
def test_code_owner_transaction_no_mappings(self, mock_set_custom_attribute):
242242
request = RequestFactory().get('/bad/path/')
243243
self.middleware(request)

0 commit comments

Comments
 (0)