Skip to content

Commit

Permalink
ref: skip event pre-normalize through CanonicalKeyDict (#70853)
Browse files Browse the repository at this point in the history
keys get normalized through the relay normalization

this gets the rest of the tests passing when changing CanonicalKeyDict
to raise when legacy keys are passed -- the testsuite passes lots of
`{"message": ...}` similar to current sdks!

<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry committed May 14, 2024
1 parent 85ededb commit 2f7ff9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/sentry/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def __init__(
project_config: Any | None = None,
sent_at: datetime | None = None,
):
self._data = CanonicalKeyDict(data)
self._data: MutableMapping[str, Any] = data
self.version = version
self._project = project
# if not explicitly specified try to get the grouping from project_config
Expand Down Expand Up @@ -401,7 +401,7 @@ def _normalize_impl(self, project_id: int | None = None) -> None:
if pre_normalize_type in ("generic", "feedback"):
self._data["type"] = pre_normalize_type

def get_data(self) -> CanonicalKeyDict:
def get_data(self) -> MutableMapping[str, Any]:
return self._data

@sentry_sdk.tracing.trace
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/web/frontend/debug/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def get(self, request: AuthenticatedHttpRequest) -> HttpResponse:
event_type = get_event_type(data)

event = eventstore.backend.create_event(
event_id="a" * 32, group_id=group.id, project_id=project.id, data=data.data
event_id="a" * 32, group_id=group.id, project_id=project.id, data=data
)

group.message = event.search_message
Expand Down Expand Up @@ -532,7 +532,7 @@ def digest(request):
)

event = eventstore.backend.create_event(
event_id=uuid.uuid4().hex, group_id=group.id, project_id=project.id, data=data.data
event_id=uuid.uuid4().hex, group_id=group.id, project_id=project.id, data=data
)
records.append(
Record(
Expand Down
4 changes: 2 additions & 2 deletions tests/sentry/event_manager/test_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ def test_deprecated_attrs(key):
assert not data.get("errors")


def test_returns_canonical_dict():
def test_returns_canonical_dict_after_normalization():
from sentry.utils.canonical import CanonicalKeyDict

event = make_event()

manager = EventManager(event)
assert isinstance(manager.get_data(), CanonicalKeyDict)
assert not isinstance(manager.get_data(), CanonicalKeyDict)
manager.normalize()
assert isinstance(manager.get_data(), CanonicalKeyDict)

Expand Down

0 comments on commit 2f7ff9a

Please sign in to comment.