diff --git a/codecov_cli/helpers/ci_adapters/base.py b/codecov_cli/helpers/ci_adapters/base.py index 37af9420..de6e14ff 100644 --- a/codecov_cli/helpers/ci_adapters/base.py +++ b/codecov_cli/helpers/ci_adapters/base.py @@ -26,7 +26,8 @@ def get_fallback_value( if fallback_field not in self.fallback_to_method: raise ValueError("The provided fallback_field is not valid") - return self.fallback_to_method[fallback_field]() + # CI envs are often set but empty; an empty string is "no value", not a value. + return self.fallback_to_method[fallback_field]() or None def detect(self) -> bool: """ diff --git a/tests/ci_adapters/test_azure_pipelines.py b/tests/ci_adapters/test_azure_pipelines.py index 6a635bfb..5eddf577 100644 --- a/tests/ci_adapters/test_azure_pipelines.py +++ b/tests/ci_adapters/test_azure_pipelines.py @@ -118,6 +118,13 @@ def test_job_code(self, env_dict, expected, mocker): "123", ), ({AzurePipelinesEnvEnum.SYSTEM_PULLREQUEST_PULLREQUESTID: "111"}, "111"), + ( + { + AzurePipelinesEnvEnum.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER: "", + AzurePipelinesEnvEnum.SYSTEM_PULLREQUEST_PULLREQUESTID: "", + }, + None, + ), ], ) def test_pull_request_number(self, env_dict, expected, mocker):