From 0e47ab1c3872ed518c7912a0656eae34c5462b15 Mon Sep 17 00:00:00 2001 From: Vladimir Kochnev Date: Fri, 13 Nov 2020 22:13:29 +0300 Subject: [PATCH 1/2] Check botocore version when activating integration Fixes #920. --- sentry_sdk/integrations/boto3.py | 9 +++++++++ tox.ini | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/boto3.py b/sentry_sdk/integrations/boto3.py index 573a6248bd..f2e72a994e 100644 --- a/sentry_sdk/integrations/boto3.py +++ b/sentry_sdk/integrations/boto3.py @@ -14,6 +14,7 @@ from typing import Type try: + from botocore import __version__ as BOTOCORE_VERSION from botocore.client import BaseClient # type: ignore from botocore.response import StreamingBody # type: ignore from botocore.awsrequest import AWSRequest # type: ignore @@ -27,6 +28,14 @@ class Boto3Integration(Integration): @staticmethod def setup_once(): # type: () -> None + try: + version = tuple(map(int, BOTOCORE_VERSION.split(".")[:3])) + except (ValueError, TypeError): + raise DidNotEnable( + "Unparsable botocore version: {}".format(BOTOCORE_VERSION) + ) + if version < (1, 12): + raise DidNotEnable("Botocore 1.12 or newer is required.") orig_init = BaseClient.__init__ def sentry_patched_init(self, *args, **kwargs): diff --git a/tox.ini b/tox.ini index f5d745b40c..8c32a88fcd 100644 --- a/tox.ini +++ b/tox.ini @@ -83,7 +83,7 @@ envlist = {py3.6,py3.7,py3.8}-chalice-{1.16,1.17,1.18,1.19,1.20} - {py2.7,py3.6,py3.7,py3.8}-boto3-{1.14,1.15,1.16} + {py2.7,py3.6,py3.7,py3.8}-boto3-{1.9,1.10,1.11,1.12,1.13,1.14,1.15,1.16} [testenv] deps = @@ -234,6 +234,11 @@ deps = chalice-1.20: chalice>=1.20.0,<1.21.0 chalice: pytest-chalice==0.0.5 + boto3-1.9: boto3>=1.9,<1.10 + boto3-1.10: boto3>=1.10,<1.11 + boto3-1.11: boto3>=1.11,<1.12 + boto3-1.12: boto3>=1.12,<1.13 + boto3-1.13: boto3>=1.13,<1.14 boto3-1.14: boto3>=1.14,<1.15 boto3-1.15: boto3>=1.15,<1.16 boto3-1.16: boto3>=1.16,<1.17 From 351b27fe5c9999a7b0f0171c3129464faa0173b1 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Thu, 19 Nov 2020 10:32:16 +0100 Subject: [PATCH 2/2] fix linters --- sentry_sdk/integrations/boto3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/boto3.py b/sentry_sdk/integrations/boto3.py index f2e72a994e..e65f5a754b 100644 --- a/sentry_sdk/integrations/boto3.py +++ b/sentry_sdk/integrations/boto3.py @@ -14,7 +14,7 @@ from typing import Type try: - from botocore import __version__ as BOTOCORE_VERSION + from botocore import __version__ as BOTOCORE_VERSION # type: ignore from botocore.client import BaseClient # type: ignore from botocore.response import StreamingBody # type: ignore from botocore.awsrequest import AWSRequest # type: ignore