From c046e8efcede510d2b73bc6943a95f7a0bed133c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Feb 2026 03:14:14 +0000 Subject: [PATCH 1/2] Fix tags error handling in connect_timelapse worker Check for missing/empty tags before attempting to convert to set, preventing TypeError when tags are None. Use sendError with info message and return gracefully instead of raising an exception. https://claude.ai/code/session_01GRr1rfjTWiPomHhCzy8NZG --- workers/annotations/connect_timelapse/entrypoint.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/workers/annotations/connect_timelapse/entrypoint.py b/workers/annotations/connect_timelapse/entrypoint.py index 75bdc6e..a09b486 100644 --- a/workers/annotations/connect_timelapse/entrypoint.py +++ b/workers/annotations/connect_timelapse/entrypoint.py @@ -170,14 +170,16 @@ def compute(datasetId, apiUrl, token, params): assignment, channel, connectTo, tags, tile, workerInterface = itemgetter( *keys)(params) - object_tag = list(set(workerInterface.get('Object to connect tag', None))) + object_tags_raw = workerInterface.get('Object to connect tag', None) + if not object_tags_raw or len(object_tags_raw) == 0: + sendError("No object tag specified", + info="Please specify an 'Object to connect tag' in the worker interface") + return + + object_tag = list(set(object_tags_raw)) max_distance = float(workerInterface['Max distance']) gap_size = int(workerInterface['Connect across gaps']) - if not object_tag or len(object_tag) == 0: - sendError("No object tag specified") - raise ValueError("No object tag specified") - print( f"Connecting {object_tag} objects across {gap_size} time slices " f"with a max distance of {max_distance} pixels") From d762a27bd17ea28b3898c078c5ce2280f9ede92d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Feb 2026 03:43:18 +0000 Subject: [PATCH 2/2] Add tests for missing tags error handling in connect_timelapse - Replace old test that expected ValueError with three new tests - Test empty list, None, and missing key scenarios - Verify sendError is called with correct message and info - Verify worker returns early without fetching annotations https://claude.ai/code/session_01GRr1rfjTWiPomHhCzy8NZG --- .../tests/test_connect_timelapse.py | 53 ++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/workers/annotations/connect_timelapse/tests/test_connect_timelapse.py b/workers/annotations/connect_timelapse/tests/test_connect_timelapse.py index 62e997a..05034d6 100644 --- a/workers/annotations/connect_timelapse/tests/test_connect_timelapse.py +++ b/workers/annotations/connect_timelapse/tests/test_connect_timelapse.py @@ -167,14 +167,55 @@ def test_basic_compute(mock_get_annotations, mock_send_progress, mock_annotation assert all('tags' in conn for conn in connections) -def test_compute_no_object_tag(mock_annotation_client, sample_params): - """Test error handling when no object tag is specified""" - # Remove object tag from params +@patch('entrypoint.sendError') +def test_compute_no_object_tag_empty_list(mock_send_error, mock_annotation_client, sample_params): + """Test error handling when object tag is an empty list""" + # Set object tag to empty list sample_params['workerInterface']['Object to connect tag'] = [] - # Should raise ValueError - with pytest.raises(ValueError, match="No object tag specified"): - compute('test_dataset', 'http://test-api', 'test-token', sample_params) + # Should call sendError and return gracefully + compute('test_dataset', 'http://test-api', 'test-token', sample_params) + + mock_send_error.assert_called_once_with( + "No object tag specified", + info="Please specify an 'Object to connect tag' in the worker interface" + ) + # Should not proceed to fetch annotations + mock_annotation_client.getAnnotationsByDatasetId.assert_not_called() + + +@patch('entrypoint.sendError') +def test_compute_no_object_tag_none(mock_send_error, mock_annotation_client, sample_params): + """Test error handling when object tag is None""" + # Set object tag to None + sample_params['workerInterface']['Object to connect tag'] = None + + # Should call sendError and return gracefully + compute('test_dataset', 'http://test-api', 'test-token', sample_params) + + mock_send_error.assert_called_once_with( + "No object tag specified", + info="Please specify an 'Object to connect tag' in the worker interface" + ) + # Should not proceed to fetch annotations + mock_annotation_client.getAnnotationsByDatasetId.assert_not_called() + + +@patch('entrypoint.sendError') +def test_compute_no_object_tag_missing_key(mock_send_error, mock_annotation_client, sample_params): + """Test error handling when Object to connect tag key is missing from workerInterface""" + # Remove the key entirely + del sample_params['workerInterface']['Object to connect tag'] + + # Should call sendError and return gracefully + compute('test_dataset', 'http://test-api', 'test-token', sample_params) + + mock_send_error.assert_called_once_with( + "No object tag specified", + info="Please specify an 'Object to connect tag' in the worker interface" + ) + # Should not proceed to fetch annotations + mock_annotation_client.getAnnotationsByDatasetId.assert_not_called() @patch('annotation_client.utils.sendProgress')