Skip to content

[18.0][FIX] sentry: event dropped if include_context key not present - #3342

Merged
OCA-git-bot merged 1 commit into
OCA:18.0from
StefanRijnhart:18.0-sentry-fix_event_dropped_when_key_not_present
Aug 20, 2025
Merged

OCA-git-bot merged 1 commit into
OCA:18.0from
StefanRijnhart:18.0-sentry-fix_event_dropped_when_key_not_present

Conversation

@StefanRijnhart

@StefanRijnhart StefanRijnhart commented Aug 12, 2025

Copy link
Copy Markdown
Member

In our (Odoo.sh) setup, we were missing almost all events after migrating to Odoo 18. With this fix, the events were back.

Fixes

  File "/home/odoo/.local/lib/python3.12/site-packages/sentry_sdk/client.py", line 595, in _prepare_event
    new_event = before_send(event, hint or {})
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/user/oca-server-tools/sentry/hooks.py", line 66, in before_send
    if event.setdefault("tags", {})["include_context"]:
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'include_context'
2025-07-08 14:45:45,907 14296 INFO quatra-18-0-development-21441249 sentry_sdk.errors: before send dropped event

NB. This error is only logged when running Sentry in debug mode, otherwise events are dropped silently.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @moylop260, @naglis, @fernandahf, @versada, @barsi,
some modules you are maintaining are being modified, check this out!

@StefanRijnhart
StefanRijnhart force-pushed the 18.0-sentry-fix_event_dropped_when_key_not_present branch from 688b20e to cfec327 Compare August 12, 2025 08:35
@StefanRijnhart

This comment was marked as outdated.

Fixes

```
  File "/home/odoo/.local/lib/python3.12/site-packages/sentry_sdk/client.py", line 595, in _prepare_event
    new_event = before_send(event, hint or {})
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/user/oca-server-tools/sentry/hooks.py", line 66, in before_send
    if event.setdefault("tags", {})["include_context"]:
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'include_context'
2025-07-08 14:45:45,907 14296 INFO quatra-18-0-development-21441249 sentry_sdk.errors: before send dropped event
```

Error is only logged when running Sentry in debug mode, otherwise events are dropped silently.
@StefanRijnhart
StefanRijnhart force-pushed the 18.0-sentry-fix_event_dropped_when_key_not_present branch from cfec327 to 9b36741 Compare August 14, 2025 20:32
@moylop260

Copy link
Copy Markdown
Contributor

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 18.0-ocabot-merge-pr-3342-by-moylop260-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 88ecb81 into OCA:18.0 Aug 20, 2025
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at cbc00c9. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants