Skip to content

[FIX] sentry: start on sentry-sdk newer than 1.9.0 - #12

Merged
yibudak merged 1 commit into
altinkaya-opensource:16.0from
IKBAL812:fix/sentry-sdk-renamed-options
Sep 14, 2026
Merged

yibudak merged 1 commit into
altinkaya-opensource:16.0from
IKBAL812:fix/sentry-sdk-renamed-options

Conversation

@IKBAL812

Copy link
Copy Markdown
Member

Production stopped on 14 September after the deploy installed sentry-sdk 1.45.1 (altinkaya-opensource/odoo#753, reverted in OCA#763):

File "/opt/odoo/v16/addons/sentry/hooks.py", line 153, in post_load
    initialize_sentry(odoo_config)
File "/opt/odoo/v16/addons/sentry/const.py", line 84, in get_sentry_options
    SentryOption("with_locals", DEFAULT_OPTIONS["with_locals"], None),
KeyError: 'with_locals'

Cause

get_sentry_options() indexes sentry_sdk.consts.DEFAULT_OPTIONS with the 1.9.0 option names. sentry-sdk renamed two of them after that release: with_locals is now include_local_variables and request_bodies is now max_request_body_size. post_load runs at every server start when sentry_enabled is set, so any newer SDK kills the process before the registry loads. That is why OCA pins sentry_sdk<=1.9.0 on 16.0 and 17.0; 18.0 moved to sentry-sdk 2.x with the new names. OCA#3104 and OCA#3105 fix the same two keys on 16.0 and are still open.

Change

  • const.py: renamed_option(new_key, old_key) returns the option under whichever name the installed SDK has. Both entries use it, so the module runs on 1.9.0 and on the 1.45 line, and you can deploy the module and the SDK in either order.
  • __manifest__.py: pin sentry_sdk<2 (2.x drops sentry_sdk._compat, which processor.py and logutils.py still import), version 16.0.3.0.4.

An odoo.conf that sets sentry_with_locals or sentry_request_bodies has to switch to the new names once the SDK is upgraded; a newer SDK ignores the old keys.

Verified

The module's 15 tests, which call initialize_sentry with a config, on a 16.0 database:

sentry-sdk result utcfromtimestamp warnings in the log
1.9.0 0 failed, 0 errors 16
1.45.1 0 failed, 0 errors 0

Deploy this before re-applying the sentry-sdk==1.45.1 bump in the odoo repository.

🤖 Generated with Claude Code

https://claude.ai/code/session_017v5D6URyGjKniyPfghTuvy

sentry-sdk renamed two client options after 1.9.0: with_locals became
include_local_variables and request_bodies became max_request_body_size.
get_sentry_options() indexed DEFAULT_OPTIONS by the old names, so any newer
SDK made post_load raise KeyError: 'with_locals' and the server never started.

renamed_option() picks whichever name the installed SDK knows, so the module
runs on 1.9.0 and on the 1.45 line alike, and the manifest pin becomes
sentry_sdk<2 (2.x drops sentry_sdk._compat, which processor.py and
logutils.py still import). An odoo.conf that sets sentry_with_locals or
sentry_request_bodies has to switch to the new names once the SDK is upgraded.

Same problem as OCA#3104 and OCA#3105, kept compatible with both
SDK generations so the module and the SDK can be deployed in either order.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017v5D6URyGjKniyPfghTuvy
@yibudak
yibudak merged commit 8bd5d64 into altinkaya-opensource:16.0 Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants