Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import module 'lambda_function': cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl #305

Open
mahela-aws opened this issue May 19, 2023 · 9 comments
Assignees

Comments

@mahela-aws
Copy link

Describe the bug
After updating to the latest verision, we are getting the below error
Unable to import module 'lambda_function': cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_

Layer Version ARN:
arn:aws:lambda:eu-central-1:770693421928:layer:Klayers-p39-requests:13

Framework:
terraform

@BMorinDrifter
Copy link

Ran into this as well because the version we were using was deprecated, which broke our terraform.

On that note, can klayers stop deprecating layers?

@ryandeivert
Copy link
Contributor

We also were hit by this. The root cause appears to be a dependency conflict with the default urllib3 version that is bundled in the lambda runtime. botocore is not update to support urllib3 v2.0.0, while requests was updated for support (as of v2.30.0).

This thread covers the issue fairly well.

Separately: I noticed that the p310 layers ONLY include the latest requests version that suffers from this issue. I'd suggest yanking that version and maybe somehow deploying version <2.30.0. You may also want to yank the latest version for <=p39 as well.

@nateprewitt
Copy link

To quickly clarify, Requests supports both urllib3 1.x and 2.x. You can continue upgrading Requests to get new features/security patches, urllib3 just needs to be pinned urllib3<2 for your layer.

@ryandeivert
Copy link
Contributor

@nateprewitt yes sorry - I was mostly referring to all of this within the context of the version Klayers is using for the layer it is creating. I'm not sure if the build pipeline has the ability to enforce constraints for layer dependencies (eg: via a constraints file), but maybe @keithrozario could chime in?

@keithrozario
Copy link
Owner

keithrozario commented May 21, 2023

Thanks @ryandeivert for the added info.

This is a tough one for me. It seems requests and boto3 have a dependency conflict -- i.e. they both depend on different versions of urrlib3 and hence are not compatible with each other (at least for requests > 2.30.0)

At the moment the pipeline is relatively rigid (it can only build the latest version automatically), I can probably modify some stuff to fix this but I'm reluctant to do this-- the main one being that at some point they're looking to make boto3 compatible with the latest urllib3 which should fix this issue. Plus the only reason this project has lasted as long as it has is that I haven't had to manually modify stuff for specific packages -- that's a slippery slope in terms of maintenance overhead that I'm a hesitant to go down.

Hence I'm leaning towards doing nothing for now -- if you're using python3.9 you can use the non-latest version, and I'll ensure we don't expire it. Expired layers last 1 year now, so there's room for flex, but I'm also open to extending this beyond 1 year -- but there has to be some deprecation :).

I'm also considering manually creating a requests layer for python3.10, so at least they have something to use.

Thoughts @ryandeivert @nateprewitt @mahela-aws ?

@mahela-aws
Copy link
Author

quick workaround we did, we pinned the layer as below, hopefully helps some of the others facing the same issue here,

data "klayers_package_all_versions" "requests" {
  name   = "requests"
  region = var.aws_region
}

# within lambda

layers = [
    # this pins the layer to arn:aws:lambda:eu-central-1:770693421928:layer:Klayers-p39-requests:11
    data.klayers_package_all_versions.requests.arns[1] 
  ]

@keithrozario
Copy link
Owner

Thanks @mahela-aws

I will remove requests from the list of built packages for p39, p310 and p310-arm64. This ensures we don't build any new versions till the issue is resolved.

@keithrozario
Copy link
Owner

Does anyone know if the issue here still persists?

@jrobison-sb
Copy link

@keithrozario I stumbled into this myself today, so yes, it does seem to still persist.

I was able to reproduce the problem using runtime python3.10 and using layer arn:aws:lambda:us-east-1:770693421928:layer:Klayers-p310-requests:3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants