8000 [16.0][FIX] sentry: apply sentry_ignore_exceptions to exceptions logged without exc_info by Miftahussalam · Pull Request #3816 · OCA/server-tools · GitHub
[go: up one dir, main page]

Skip to content

[16.0][FIX] sentry: apply sentry_ignore_exceptions to exceptions logged without exc_info - #3816

Open
Miftahussalam wants to merge 2 commits into
OCA:16.0from
Miftahussalam:16.0-fix-sentry-ignore-exceptions
Open

Miftahussalam wants to merge 2 commits into
OCA:16.0from
Miftahussalam:16.0-fix-sentry-ignore-exceptions

Conversation

@Miftahussalam
Copy link
Copy Markdown

Fixes #3815

before_send dropped the log records whose message is an exception by the fixed const.DEFAULT_IGNORED_EXCEPTIONS list. Odoo logs the UserError and AccessError of a request like that (_logger.warning(exc), no exc_info), so sentry_ignore_exceptions did not apply to them: emptying it did not let a ValidationError through.

The list of the configuration (ignore_errors of the client) is applied now, with the same matching as sentry_sdk does for an exc_info (the full class name, or the class name). The default value of the option is the same list as before, so the default behaviour does not change.

Also: the table of readme/CONFIGURE.rst named the option sentry_ignored_exceptions, the code reads sentry_ignore_exceptions.

Tests

  • test_capture_exceptions_with_no_exc_info used to patch the constant; it sets sentry_ignore_exceptions empty now.
  • New test_ignore_exceptions_with_no_exc_info_from_config: with sentry_ignore_exceptions = odoo.exceptions.ValidationError, a ValidationError is ignored and a UserError is captured.
  • test_ignore_exceptions_with_no_exc_info (default list) still passes.

The whole sentry test suite passes (16 tests, 0 failed). Without the change to hooks.py, the two tests above fail.

This is for 16.0; the same code is in 17.0, 18.0 and 19.0, I can port it if the change is accepted.

…hout exc_info

before_send dropped the log records whose message is an exception (how Odoo logs
UserError and AccessError in odoo/http.py: logger.warning(exc), no exc_info) by
the fixed DEFAULT_IGNORED_EXCEPTIONS list, so sentry_ignore_exceptions had no
effect on them: emptying the option did not let a ValidationError through.

The same list of the configuration (ignore_errors of the client) is applied now,
with the same matching as sentry_sdk does for an exc_info.

Also fix the option name in the documentation: the code reads
sentry_ignore_exceptions, the table said sentry_ignored_exceptions.
@OCA-git-bot
Copy link
Copy Markdown
Contributor

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

Use the sentry_ignore_exceptions option directly instead of the client options,
so that the check has no branch for a missing client or for classes, which the
module never passes: the option is a list of names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0