Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 Resolve KeyError for missing 'event_id' #66344

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/sentry/eventstore/processing/base.py
Expand Up @@ -38,6 +38,9 @@ def exists(self, event: Event) -> bool:
return self.get(key) is not None

def store(self, event: Event, unprocessed: bool = False) -> str:
if not event.get('event_id') or not event.get('project'):
logger.error(f\"store method called with event missing 'event_id' or 'project'. Event data: {event}\")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we have a policy around logging every error event in the errors pipeline, but this seems risky

return
with sentry_sdk.start_span(op="eventstore.processing.store"):
key = cache_key_for_event(event)
if unprocessed:
Expand Down
8 changes: 6 additions & 2 deletions src/sentry/utils/cache.py
Expand Up @@ -40,5 +40,9 @@ def __get__(self, obj: Any, type: Any = None) -> T:
return value


def cache_key_for_event(data: Mapping[str, Any]) -> str:
return "e:{}:{}".format(data["event_id"], data["project"])
def cache_key_for_event(data: Mapping[str, Any]) -> str:
event_id = data.get('event_id', 'unknown_event_id')
project = data.get('project', 'unknown_project')
if event_id == 'unknown_event_id' or project == 'unknown_project':
logger.error(f\"cache_key_for_event called with missing data. event_id: {event_id}, project: {project}\")
return \"e:{}:{}'.format(event_id, project)