diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e1c2490..666b54a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Address `SlackAPIRatelimitError` exceptions in `apps.slack.tasks.send_message_to_thread_if_bot_not_in_channel` task by @joeyorlando ([#3803](https://github.com/grafana/oncall/pull/3803)) +- Fix exception when parsing incident plugin config @mderynck ([#3802](https://github.com/grafana/oncall/pull/3802)) ## v1.3.96 (2024-01-31) diff --git a/engine/apps/user_management/sync.py b/engine/apps/user_management/sync.py index fd8256e1..df0ce19b 100644 --- a/engine/apps/user_management/sync.py +++ b/engine/apps/user_management/sync.py @@ -111,9 +111,12 @@ def _sync_grafana_incident_plugin(organization: Organization, grafana_api_client It intended to use only inside _sync_organization. It mutates, but not saves org, it's saved in _sync_organization. """ grafana_incident_settings, _ = grafana_api_client.get_grafana_incident_plugin_settings() + organization.is_grafana_incident_enabled = False + organization.grafana_incident_backend_url = None + if grafana_incident_settings is not None: organization.is_grafana_incident_enabled = grafana_incident_settings["enabled"] - organization.grafana_incident_backend_url = grafana_incident_settings.get("jsonData", {}).get( + organization.grafana_incident_backend_url = (grafana_incident_settings.get("jsonData") or {}).get( GrafanaAPIClient.GRAFANA_INCIDENT_PLUGIN_BACKEND_URL_KEY ) diff --git a/engine/apps/user_management/tests/test_sync.py b/engine/apps/user_management/tests/test_sync.py index 158f1378..96a86bae 100644 --- a/engine/apps/user_management/tests/test_sync.py +++ b/engine/apps/user_management/tests/test_sync.py @@ -541,6 +541,7 @@ class TestSyncGrafanaIncidentParams: MOCK_GRAFANA_INCIDENT_BACKEND_URL, ), TestSyncGrafanaIncidentParams(({"enabled": True}, None), True, None), + TestSyncGrafanaIncidentParams(({"enabled": True, "jsonData": None}, None), True, None), # missing jsonData (sometimes this is what we get back from the Grafana API) TestSyncGrafanaIncidentParams(({"enabled": False}, None), False, None), # plugin is disabled for some reason ],