diff --git a/codecov_cli/helpers/encoder.py b/codecov_cli/helpers/encoder.py index 167a817e..6af996dc 100644 --- a/codecov_cli/helpers/encoder.py +++ b/codecov_cli/helpers/encoder.py @@ -1,5 +1,7 @@ import re +import click + slug_without_subgroups_regex = re.compile(r"[^/\s]+\/[^/\s]+$") slug_with_subgroups_regex = re.compile(r"[^/\s]+(\/[^/\s]+)+$") encoded_slug_regex = re.compile(r"[^:\s]+(:::[^:\s]+)*(::::[^:\s]+){1}$") @@ -7,7 +9,9 @@ def encode_slug(slug: str): if slug_with_subgroups_is_invalid(slug): - raise ValueError("The provided slug is invalid") + raise click.ClickException( + "The provided slug is invalid. Slug must be in the format /" + ) owner, repo = slug.rsplit("/", 1) encoded_owner = ":::".join(owner.split("/")) encoded_slug = "::::".join([encoded_owner, repo]) diff --git a/codecov_cli/opentelemetry.py b/codecov_cli/opentelemetry.py index b902a433..81acc047 100644 --- a/codecov_cli/opentelemetry.py +++ b/codecov_cli/opentelemetry.py @@ -8,6 +8,7 @@ _SAMPLED_MESSAGES = [ "Token required", "No JUnit XML reports found", + "The provided slug is invalid", ] _SAMPLE_RATE = 100 _SKIP_TAG_KEYS = {"branch", "flags", "commit_sha", "env_vars"}