From 20fcc5498d81422d08d8b886ecd0d0ceb71123ff Mon Sep 17 00:00:00 2001 From: Burak Kaan Alkan Date: Mon, 14 Sep 2026 10:33:40 +0300 Subject: [PATCH] [FIX] sentry: start on sentry-sdk newer than 1.9.0 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/server-tools#3104 and #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 Claude-Session: https://claude.ai/code/session_017v5D6URyGjKniyPfghTuvy --- sentry/__manifest__.py | 4 ++-- sentry/const.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sentry/__manifest__.py b/sentry/__manifest__.py index 1d380228d9f..60c45fcd102 100644 --- a/sentry/__manifest__.py +++ b/sentry/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Sentry", "summary": "Report Odoo errors to Sentry", - "version": "16.0.3.0.3", + "version": "16.0.3.0.4", "category": "Extra Tools", "website": "https://github.com/OCA/server-tools", "author": "Mohammed Barsi," @@ -17,7 +17,7 @@ "installable": True, "external_dependencies": { "python": [ - "sentry_sdk<=1.9.0", + "sentry_sdk<2", ] }, "depends": [ diff --git a/sentry/const.py b/sentry/const.py index 78b783bddf8..595fe8fc4ec 100644 --- a/sentry/const.py +++ b/sentry/const.py @@ -76,12 +76,22 @@ def get_sentry_logging(level=DEFAULT_LOG_LEVEL): ) +def renamed_option(new_key, old_key, converter=None): + """An option sentry-sdk renamed after 1.9.0, under the installed SDK's name. + + ``sentry_sdk.init`` rejects the other name, and reading the missing key from + ``DEFAULT_OPTIONS`` raised KeyError at server start once the SDK was upgraded. + """ + key = new_key if new_key in DEFAULT_OPTIONS else old_key + return SentryOption(key, DEFAULT_OPTIONS[key], converter) + + def get_sentry_options(): res = [ SentryOption("dsn", "", str.strip), SentryOption("transport", DEFAULT_OPTIONS["transport"], select_transport), SentryOption("logging_level", DEFAULT_LOG_LEVEL, get_sentry_logging), - SentryOption("with_locals", DEFAULT_OPTIONS["with_locals"], None), + renamed_option("include_local_variables", "with_locals"), SentryOption( "max_breadcrumbs", DEFAULT_OPTIONS["max_breadcrumbs"], to_int_if_defined ), @@ -107,7 +117,7 @@ def get_sentry_options(): SentryOption("http_proxy", DEFAULT_OPTIONS["http_proxy"], None), SentryOption("https_proxy", DEFAULT_OPTIONS["https_proxy"], None), SentryOption("ignore_exceptions", DEFAULT_IGNORED_EXCEPTIONS, split_multiple), - SentryOption("request_bodies", DEFAULT_OPTIONS["request_bodies"], None), + renamed_option("max_request_body_size", "request_bodies"), SentryOption("attach_stacktrace", DEFAULT_OPTIONS["attach_stacktrace"], None), SentryOption("ca_certs", DEFAULT_OPTIONS["ca_certs"], None), SentryOption("propagate_traces", DEFAULT_OPTIONS["propagate_traces"], None),