diff --git a/ddtrace/internal/ci_visibility/recorder.py b/ddtrace/internal/ci_visibility/recorder.py index 6a3121b35e0..f3d70d6b58f 100644 --- a/ddtrace/internal/ci_visibility/recorder.py +++ b/ddtrace/internal/ci_visibility/recorder.py @@ -554,6 +554,12 @@ def _fetch_tests_to_skip(self, skipping_mode: str): self._test_suites_to_skip = [] self._tests_to_skip = defaultdict(list) + except Exception: + log.warning("Error retrieving skippable test data, no tests will be skipped", exc_info=True) + error_type = ERROR_TYPES.UNKNOWN + self._test_suites_to_skip = [] + self._tests_to_skip = defaultdict(list) + finally: record_itr_skippable_request( sw.elapsed() * 1000, diff --git a/releasenotes/notes/ci-visibility-handle-exception-in-tests-to-skip-675db3b857f8e232.yaml b/releasenotes/notes/ci-visibility-handle-exception-in-tests-to-skip-675db3b857f8e232.yaml new file mode 100644 index 00000000000..fe63970e61a --- /dev/null +++ b/releasenotes/notes/ci-visibility-handle-exception-in-tests-to-skip-675db3b857f8e232.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + CI Visibility: This fix resolves an issue where exceptions other than timeouts and connection errors raised + while fetching the list of skippable tests for ITR were not being handled correctly and caused the tracer to + crash. diff --git a/tests/ci_visibility/test_ci_visibility.py b/tests/ci_visibility/test_ci_visibility.py index a02d9da934e..430ce6203a7 100644 --- a/tests/ci_visibility/test_ci_visibility.py +++ b/tests/ci_visibility/test_ci_visibility.py @@ -207,6 +207,25 @@ def test_ci_visibility_service_skippable_timeout(_do_request, _check_enabled_fea CIVisibility.disable() +@mock.patch( + "ddtrace.internal.ci_visibility.recorder.CIVisibility._check_enabled_features", + return_value=_CIVisibilitySettings(True, True, False, True), +) +@mock.patch("ddtrace.internal.ci_visibility.recorder._do_request", side_effect=ValueError) +def test_ci_visibility_service_skippable_other_error(_do_request, _check_enabled_features): + with override_env( + dict( + DD_API_KEY="foobar.baz", + DD_APP_KEY="foobar", + DD_CIVISIBILITY_AGENTLESS_ENABLED="1", + ) + ), _dummy_noop_git_client(): + ddtrace.internal.ci_visibility.recorder.ddconfig = _get_default_civisibility_ddconfig() + CIVisibility.enable(service="test-service") + assert CIVisibility._instance._test_suites_to_skip == [] + CIVisibility.disable() + + @mock.patch("ddtrace.internal.ci_visibility.recorder._do_request") def test_ci_visibility_service_enable_with_itr_enabled(_do_request): with override_env(