Skip to content
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Removed

## [1.4.9] - 2026-05-25

### Fixed

- Updated error handling for MQ sending so that any errors sending dataset
check results doesn't cause checker loop to exit early.

## [1.4.8] - 2026-05-18

### Removed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "bulk-data-service"
version = "1.4.8"
version = "1.4.9"
requires-python = ">= 3.12.6"
readme = "README.md"
dependencies = [
Expand Down
9 changes: 7 additions & 2 deletions src/utilities/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,14 @@ def send_dataset_check_result_message(context: BDSContext, msg_payload: dict, re
try:
send_message_to_iati_mq(context, topic_name, msg_payload)
break
except azure.servicebus.exceptions.ServiceBusConnectionError as e:
except azure.servicebus.exceptions.ServiceBusError as e:
if retry_number == retries:
raise RuntimeError("{}".format(e))
context.logger.error(
"Dataset check result message could not be sent to the IATI MQ after {} attempts. "
"Error details: {}".format(retry_number, e)
)
except Exception as e:
raise RuntimeError("{}".format(e))


def send_message_to_iati_mq(context: BDSContext, topic_name, msg_payload):
Expand Down
42 changes: 42 additions & 0 deletions tests/integration/test_dataset_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid

import pytest
from azure.servicebus.exceptions import ServiceBusQuotaExceededError

from bulk_data_service.checker import checker_run
from helpers.data_helpers import (
Expand Down Expand Up @@ -199,6 +200,47 @@ def test_update_dataset_registration_details(get_and_clear_up_context, field, or
assert datasets_in_bds[dataset_id][field] == expected


def test_update_dataset_mq_message_send_doesnt_crash_on_error(monkeypatch, get_and_clear_up_context): # noqa: F811

context = get_and_clear_up_context

class FailingTopicSender:
def send_messages(self, *args, **kwargs):
raise ServiceBusQuotaExceededError(
message="Test simulated service bus send failure",
)

def close(self):
return None

class FakeServiceBusClient:
def get_topic_sender(self, *args, **kwargs):
return FailingTopicSender()

def close(self):
return None

class FakeServiceFactory:
def get_service_bus_client(self, *args, **kwargs):
return FakeServiceBusClient()

def get_suitecrm_client(self):
raise NotImplementedError

monkeypatch.setattr(context, "_service_factory", FakeServiceFactory())

dataset_id = uuid.UUID("c8a40aa5-9f31-4bcf-a36f-51c1fc2cc159")

context["DATA_REGISTRY_BASE_URL"] = "http://localhost:3000/ckan-registration/datasets-01-1-dataset"
datasets_in_bds = {}
checker_run(context, datasets_in_bds)

context.logger.error.assert_called_once()
assert context.logger.error.call_args.args[0].startswith(
"Dataset check result message could not be sent to the IATI MQ"
)


def test_dataset_download_404s_then_successful(get_and_clear_up_context): # noqa: F811

context = get_and_clear_up_context
Expand Down
Loading