question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

boto3 integration broken

See original GitHub issue

Hey, I’ve recently started seeing boto3 related failures in my unit tests. The recordings had been working previously, but it seems that something has changed in boto, and the vcrpy support is no longer working.

------------------------------------------------------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------------------------------------------------------
/Users/analogj/repos/lexicon/venv/lib/python2.7/site-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
1oglop1commented, Nov 26, 2018

@jeshan I have some debug information for the issue The biggest obstacle for the issue is that vcrpy does not have much logging

  1. botocore does not use vendored requests for all calls it uses botocore.awsrequest which uses urllib3 https://github.com/boto/botocore/blob/develop/botocore/awsrequest.py#L254

  2. Any call from botocore or botocore.vendored.requests does not invoke vcr.request

  3. vcr.request.Request is never called when using boto3

@kevin1024 I’d need more info how does the lib work internally because I could not figure it out what is called when.

It might be something with vcr.patch which imports botocore.verndored.requests ~3 times https://github.com/kevin1024/vcrpy/blob/master/vcr/patch.py#L410 because botocore.awsrequest has bit different implementation

and then _urllib3_patchers https://github.com/kevin1024/vcrpy/blob/master/vcr/patch.py#L306 is looking for HTTPSConnection but botocore has prefix AWS -> AWSHTTPSConnection

after couple modification I was able to get vcr.request.Request invoked and request recorded.

So in the end it was enough to patch this part https://github.com/kevin1024/vcrpy/blob/master/vcr/patch.py#L315 as:

        if cpool.__name__ == 'botocore.awsrequest':
            log.debug(f"mock {mock_triples}")
            mock_triples = (
                (cpool.AWSHTTPConnectionPool, 'ConnectionCls', stubs.VCRRequestsHTTPConnection),
                (cpool.AWSHTTPSConnectionPool, 'ConnectionCls', stubs.VCRRequestsHTTPSConnection),
            )

It is not very elegant and it’s tested now only on my dev env and boto 1 call. I will do couple more tests and then run the CI to see if tests pass.

0reactions
svdgraafcommented, Jul 25, 2019

Same here! Thanks for everyone involved! 👏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - boto3 integration broken - - Bountysource
boto3 integration broken ... Hey, I've recently started seeing boto3 related failures in my unit tests. The recordings had been working previously, but...
Read more >
boto's Glacier-to-S3 restore() function not working
I'm fairly new to both python and the S3/Glacier integration interface that boto provides. ... Or is there something innately broken about boto...
Read more >
class ACM. Client - Boto3 Docs 1.26.32 documentation
Imports a certificate into Certificate Manager (ACM) to use with services that are integrated with ACM. Note that integrated services allow only certificate ......
Read more >
Python : Pipe is broken - RPA Discussions - UiPath Forum
import base64 import boto3 def encrypt(secret): session = boto3.session. ... Thanks! Python Integration (Pipe is broken).
Read more >
Migrating to Boto3 | AWS Developer Tools Blog
To make the process of migrating to Boto3 easier, we released Boto3 under the boto3 namespace so that you can use Boto and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found