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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Resolve KeyError for missing 'event_id' #66344

Conversation

sentry-autofix-experimental[bot]
Copy link
Contributor

👋 Hi there! This PR was automatically generated 🤖

Fixes SENTRY-14S1

To fix the KeyError caused by a missing 'event_id' in the data dictionary when generating a cache key in the cache_key_for_event function, we will ensure 'event_id' and 'project' keys are present in the data dictionary before calling the function. If the keys are missing, we will add a proper handling mechanism to prevent the application from crashing and log the issue for further investigation.

The steps that were performed:

  1. Enhance cache_key_for_event to handle missing keys gracefully
  2. Ensure 'event_id' is present before storing events

📣 Instructions for the reviewer which is you, yes you:

  • If these changes were incorrect, please close this PR and comment explaining why.
  • If these changes were incomplete, please continue working on this PR then merge it.
  • If you are feeling confident in my changes, please merge this PR.

This will greatly help us improve the autofix system. Thank you! 🙏

If there are any questions, please reach out to the AI/ML Team on #proj-autofix

🤓 Stats for the nerds:

Prompt tokens: 15307
Completion tokens: 1286
Total tokens: 16593

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 5, 2024
Copy link
Member

@lynnagara lynnagara left a comment

Choose a reason for hiding this comment

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

Let's not don't drop messages, we should raise InvalidMessage and DLQ instead

@@ -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

Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.40%. Comparing base (f9c2ffd) to head (d5cf775).
Report is 1040 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #66344       +/-   ##
===========================================
- Coverage   84.30%   64.40%   -19.90%     
===========================================
  Files        5309     5301        -8     
  Lines      237200   236738      -462     
  Branches    41035    40982       -53     
===========================================
- Hits       199960   152470    -47490     
- Misses      37021    84043    +47022     
- Partials      219      225        +6     
Files Coverage Δ
src/sentry/eventstore/processing/base.py 86.48% <ø> (-8.11%) ⬇️
src/sentry/utils/cache.py 95.83% <ø> (-0.33%) ⬇️

... and 1714 files with indirect coverage changes

@getsantry
Copy link
Contributor

getsantry bot commented Mar 27, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Mar 27, 2024
@getsantry getsantry bot closed this Apr 5, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant