Sentry-python: Not working with older boto version

Created on 12 Nov 2020  路  11Comments  路  Source: getsentry/sentry-python

Hello, we use it in Django==2.1.7 app and this row breaks the app.

https://github.com/getsentry/sentry-python/blob/cc08a6bed116e09db41c712c20ab63eb0a839e41/sentry_sdk/integrations/boto3.py#L36

For versions
boto3==1.7.45
botocore==1.10.84

this throws
AttributeError: 'str' object has no attribute 'hyphenize'

I'm not sure the base of the integrations but I thought they must be enabled in settings, but this part of Boto3Integration is triggered even if we have not enabled it in django settings.

bug

Most helpful comment

FYI. i fixed those cases and runnig a test where I removed the limitation for Sentry :). Thanks for pointing in the right direction! https://github.com/apache/airflow/commit/c9f74a839eff923754a63b435635ec964b3de88a

All 11 comments

You're right this is a bug, the integration should not be enabled for unsupported boto versions. In the meantime please use auto_enabling_integrations=False as kwarg to init().

@marshall-lee can you take this issue? We have a bunch of version checks in other integrations that then raise DidNotEnable if the version is too low

You're right this is a bug, the integration should not be enabled for unsupported boto versions. In the meantime please use auto_enabling_integrations=False as kwarg to init().

Thanks, I will.

I attempted to fix it in #921.

I think we have a related problem in Apache Airflow.

Not sure if this is related to botocore version, but in our case we have this:

boto==2.49.0
boto3==1.16.18
botocore==1.19.18

And version of sentry-sdk >=0.19.0 causes this error:

self = <[AttributeError("trace_id") raised in repr()] SafeRepr object at 0x7f95c57e66e0>, trace_id = None, span_id = None, parent_span_id = None, same_process_as_parent = True, sampled = None, op = 'db'
description = 'SELECT connection.password AS connection_password, connection.extra AS connection_extra, connection.id AS connection_...crypted, connection.is_extra_encrypted AS connection_is_extra_encrypted 
FROM connection 
WHERE connection.conn_id = ?'
hub = <sentry_sdk.hub.Hub object at 0x7f95ca9ced10>, status = None, transaction = None

    def __init__(
        self,
        trace_id=None,  # type: Optional[str]
        span_id=None,  # type: Optional[str]
        parent_span_id=None,  # type: Optional[str]
        same_process_as_parent=True,  # type: bool
        sampled=None,  # type: Optional[bool]
        op=None,  # type: Optional[str]
        description=None,  # type: Optional[str]
        hub=None,  # type: Optional[sentry_sdk.Hub]
        status=None,  # type: Optional[str]
        transaction=None,  # type: Optional[str] # deprecated
    ):
        # type: (...) -> None
>       self.trace_id = trace_id or uuid.uuid4().hex
E       AttributeError: 'str' object has no attribute 'hex'

/usr/local/lib/python2.7/site-packages/sentry_sdk/tracing.py:135: AttributeError

For example here: https://github.com/apache/airflow/runs/1403411962?check_suite_focus=true#step:6:905

Limiting sentry to <0.19.0 fixes it.

Happy to provide more information if needed.

@potiuk

No it doesn't look like the same issue, it's something else. And your botocore version is compatible with Boto3Integration.

@potiuk I think you have an uuid module shadowing the stdlib. Why does uuid.uuid4() return a string? in any case please file a separate issue.

I see. that's an interesting one because it seemed only appear in case we installed sentry to version 0.19.0 - mybe simply the uuid.uuid4() is used in this version? I believe I have checked the uuid.uuid4().hex and it was working fine when I tried it (but it is also possible that it is a side effect of some tests that patch uuid4() and it is not removed.

I will double check and not open a new issue if that's the case.

Ah yeah!

@mock.patch('airflow.contrib.operators.dataproc_operator.uuid.uuid4', return_value='test')

Sorry to bother you. But that at least helped to nail down a test issue :)

FYI. i fixed those cases and runnig a test where I removed the limitation for Sentry :). Thanks for pointing in the right direction! https://github.com/apache/airflow/commit/c9f74a839eff923754a63b435635ec964b3de88a

Was this page helpful?
0 / 5 - 0 ratings