Skip to content
Draft
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
6 changes: 3 additions & 3 deletions src/sentry/models/artifactbundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections.abc import Callable, Iterable, Mapping
from enum import Enum
from types import TracebackType
from typing import IO, Any, Self, cast
from typing import IO, Any, Self

from django.db import models
from django.db.models.signals import post_delete
Expand Down Expand Up @@ -261,11 +261,11 @@ def normalize_headers(headers: dict[str, object]) -> dict[str, object]:

@staticmethod
def normalize_debug_id(debug_id: object) -> str | None:
if debug_id is None:
if not isinstance(debug_id, str):
return None

try:
return normalize_debug_id(cast(str, debug_id))
return normalize_debug_id(debug_id)
except SymbolicError:
return None

Expand Down
9 changes: 9 additions & 0 deletions tests/sentry/debug_files/test_artifact_bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ def get_indexed_files(
return list(query)


def test_normalize_debug_id_rejects_non_strings() -> None:
assert ArtifactBundleArchive.normalize_debug_id(None) is None
assert ArtifactBundleArchive.normalize_debug_id(123) is None
assert (
ArtifactBundleArchive.normalize_debug_id("aaaaaaaa-0000-0000-0000-000000000000")
== "aaaaaaaa-0000-0000-0000-000000000000"
)


class ArtifactLookupTest(TestCase):
def clear_cache(self) -> None:
redis_client = get_redis_cluster_for_artifact_bundles()
Expand Down
Loading