From 00ea990cabe5f53da7200eb179837a03f9d95d18 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 14 Feb 2022 19:29:16 -0300 Subject: [PATCH] Sentry: ignore logging known exceptions By reading https://docs.sentry.io/clients/python/integrations/#additional-settings it seems that we should be able to ignore known exceptions to be sent to Sentry. Note that we have this setting already defined at https://github.com/readthedocs/readthedocs.org/blob/b5908b0fc65cb02fc840b23eeb4218b3115b6590/readthedocs/settings/base.py#L453 However, we need to add these known exceptions to https://github.com/readthedocs/readthedocs.org/blob/b5908b0fc65cb02fc840b23eeb4218b3115b6590/readthedocs/projects/tasks/builds.py#L224-L229 This commit adds the known exceptions to be ignored by Celery and not sent to Sentry either. --- readthedocs/projects/tasks/builds.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/readthedocs/projects/tasks/builds.py b/readthedocs/projects/tasks/builds.py index 4acf845887e..198eac2088b 100644 --- a/readthedocs/projects/tasks/builds.py +++ b/readthedocs/projects/tasks/builds.py @@ -53,6 +53,7 @@ DuplicatedBuildError, ProjectBuildsSkippedError, YAMLParseError, + MkDocsYAMLParseError, ) from readthedocs.doc_builder.loader import get_builder_class from readthedocs.doc_builder.python_environments import Conda, Virtualenv @@ -62,7 +63,7 @@ from readthedocs.worker import app -from ..exceptions import RepositoryError +from ..exceptions import RepositoryError, ProjectConfigurationError from ..models import APIProject, Feature, WebHookEvent, HTMLFile, ImportedFile, Project from ..signals import ( after_build, @@ -220,12 +221,21 @@ class UpdateDocsTask(SyncRepositoryMixin, Task): max_retries = 5 # 5 per normal builds, 25 per concurrency limited default_retry_delay = 7 * 60 - # Expected exceptions that will be logged as info only and not retried + # Expected exceptions that will be logged as info only and not retried. + # These exceptions are not sent to Sentry either because we are using + # ``SENTRY_CELERY_IGNORE_EXPECTED=True``. + # + # All exceptions generated by a user miss-configuration should be listed + # here. Actually, every subclass of ``BuildUserError``. throws = ( DuplicatedBuildError, ProjectBuildsSkippedError, ConfigError, YAMLParseError, + BuildUserError, + RepositoryError, + MkDocsYAMLParseError, + ProjectConfigurationError, ) acks_late = True