Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bug when CODE_OWNER_MAPPINGS not defined #464

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Change Log

.. There should always be an "Unreleased" section for changes pending release.

7.0.1 - 2024-11-21
------------------
Fixed
~~~~~
* Fix bug where code owner custom attributes were being defined, even when the CODE_OWNER_MAPPINGS setting was not defined.

7.0.0 - 2024-10-16
------------------
Removed
Expand Down
2 changes: 1 addition & 1 deletion edx_django_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
EdX utilities for Django Application development..
"""

__version__ = "7.0.0"
__version__ = "7.0.1"

default_app_config = (
"edx_django_utils.apps.EdxDjangoUtilsConfig"
Expand Down
4 changes: 3 additions & 1 deletion edx_django_utils/monitoring/internal/code_owner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def get_code_owner_mappings():
# .. setting_description: Used for monitoring and reporting of ownership. Use a
# dict with keys of code owner name and value as a list of dotted path
# module names owned by the code owner.
code_owner_mappings = getattr(settings, 'CODE_OWNER_MAPPINGS', {})
code_owner_mappings = getattr(settings, 'CODE_OWNER_MAPPINGS', None)
if code_owner_mappings is None:
return None

try:
for code_owner in code_owner_mappings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ def test_code_owner_transaction_mapping_error(self, mock_newrelic_agent, mock_se
mock_set_custom_attribute, has_path_error=True, has_transaction_error=True
)

@patch('edx_django_utils.monitoring.internal.code_owner.utils.set_custom_attribute')
@patch('edx_django_utils.monitoring.internal.code_owner.middleware.set_custom_attribute')
def test_code_owner_no_mappings(self, mock_set_custom_attribute):
request = RequestFactory().get('/test/')
self.middleware(request)
mock_set_custom_attribute.assert_not_called()

@patch('edx_django_utils.monitoring.internal.code_owner.utils.set_custom_attribute')
@patch('edx_django_utils.monitoring.internal.code_owner.middleware.set_custom_attribute')
def test_code_owner_transaction_no_mappings(self, mock_set_custom_attribute):
request = RequestFactory().get('/bad/path/')
self.middleware(request)
Expand Down