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

Allow urllib3 2.0.0 to be installed #2926

Closed
2 tasks
epicserve opened this issue Apr 29, 2023 · 42 comments
Closed
2 tasks

Allow urllib3 2.0.0 to be installed #2926

epicserve opened this issue Apr 29, 2023 · 42 comments
Labels
dependencies This issue is a problem in a dependency. feature-request This issue requests a feature. p2 This is a standard priority issue third-party

Comments

@epicserve
Copy link

Describe the feature

There is a new version of urllib3 (v2.0.0) that can't be installed in projects that use botocore because, in the setup.py file, it has the version restriction urllib3>=1.25.4,<1.27.

Use Case

So other projects that want to upgrade to urllib3 2.0.0 can without being blocked by the botocore library.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

SDK version used

latest

Environment details (OS name and version, etc.)

all

@epicserve epicserve added feature-request This issue requests a feature. needs-triage This issue or PR still needs to be triaged. labels Apr 29, 2023
@nateprewitt
Copy link
Contributor

Hi @epicserve, thanks for reaching out. The pin is currently intentional while we wait for the major version bump to stabilize. We intend to move the pin shortly after Requests does to ensure we're not negatively impacting users.

We'll keep this issue updated and feel free to follow along in psf/requests#6432 as well if you like.

@nateprewitt nateprewitt added dependencies This issue is a problem in a dependency. third-party and removed feature-request This issue requests a feature. needs-triage This issue or PR still needs to be triaged. labels Apr 29, 2023
@jplock
Copy link

jplock commented May 4, 2023

I started getting this error message in my Lambda logs after doing a recent deploy which has to be pulling in urllib3 >=2.0.0

Runtime.ImportModuleError: Unable to import module 'app.lambda_handler': cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_' (/opt/python/urllib3/util/ssl_.py)

which is coming from https://github.com/boto/botocore/blob/master/botocore/httpsession.py#L52

try:
    from urllib3.util.ssl_ import DEFAULT_CIPHERS
except ImportError:
    # Defer to system configuration starting with
    # urllib3 2.0. This will choose the ciphers provided by
    # Openssl 1.1.1+ or secure system defaults.
    DEFAULT_CIPHERS = None

which is concerning because urllib3 removed DEFAULT_CIPHERS in urllib3/urllib3#2705 which is part of v2.0.0

What I'm not understanding is why the ImportError isn't being caught? This is using the Python 3.10 managed Lambda runtime.

@nateprewitt
Copy link
Contributor

Hi @jplock, this was already resolved in #2924. You'll likely want to ensure you're not upgrading to urllib3 2.0 for the time being or add a more recent version of Botocore to your Lambda as detailed here.

@pistolilla
Copy link

pistolilla commented May 5, 2023

Same as @jplock here. I started seeing this error today on a AWS Lambda Function after I made deployment. Tried rolling back to previous states, but error remained. Lambda uses these libraries:

unidecode==1.3.4
cleanco==2.2
spacy==3.2.2

@nateprewitt
Copy link
Contributor

nateprewitt commented May 5, 2023

Hi @pistolilla, if you're still encountering this error you'll want to add this to your dependency closure in the same way you're specifying the dependencies you've listed above. Make sure this is the last entry:

urllib3<2

One of your dependencies is pulling in the latest version of urllib3 which contains a handful of breaking changes.

@edgarrmondragon
Copy link

requests 2.30 added support for urllib3 2.0: https://github.com/psf/requests/releases/tag/v2.30.0

@tim-finnigan tim-finnigan added feature-request This issue requests a feature. p2 This is a standard priority issue labels May 8, 2023
@nateprewitt
Copy link
Contributor

Hi @edgarrmondragon, we're aware of the Requests update. This has surfaced a number of unexpected breakages within AWS infrastructure that we're currently looking at options to remedy. We'd advise users to pin to urllib3<2 in their requirements or rely on the current pin in Botocore for the time being. You can find more information in:

psf/requests#6443
urllib3/urllib3#2168

fruch added a commit to fruch/scylla-ccm that referenced this issue May 9, 2023
Look like new version of requests is pulling newer
versions of urllib3 which are not comptible with
botocore.

Ref: boto/botocore#2926
Ref: psf/requests#6443
Ref: urllib3/urllib3#2168
fruch added a commit to scylladb/scylla-ccm that referenced this issue May 10, 2023
Look like new version of requests is pulling newer
versions of urllib3 which are not comptible with
botocore.

Ref: boto/botocore#2926
Ref: psf/requests#6443
Ref: urllib3/urllib3#2168
pizen added a commit to WarnerMedia/artemis that referenced this issue May 10, 2023
Storing the SBOM dependecy tree in the database turned out to not be the
right decision due to performance issues at scale. Previous changes to
improve performance reduced the usage of the dependency table to just
generating SBOM reports. This change moves the storage of the dependency
tree from the database to S3, removing the need to deconstruct and
reconstruct the tree and removes the overhead that goes along with that.
The S3 key is structured so that other SBOM file formats, such as SPDX
or CycloneDX, could also be stored alongside.

- Update engine SBOM processing to write the dependency tree to a JSON
  file in S3 instead of the database. The dependency tree is still
  processed in order to store component and license information in the
  database.
- Update sbom_report Lambda to pull the dependency tree JSON file from
  S3. If the file is not found in S3 it falls back to pulling the tree
  from the database. This allows for the gradual migration of the
  dependency tree data from the database to S3 as new scans are run and
  old scans are purged by the db_cleanup Lambda.
- Update the db_cleanup to identify and remove dependency files that
  were orphaned when their associated scans were deleted. Deleting scans
  via the ORM will clean up the dependency files from S3. This is a
  backstop just in case a scan is deleted directly or something else
  happens that prevents the cleanup at deletion time from succeeding.
- Update localstack config to add an S3 bucket that can store dependency
  tree files during local testing and update AWSConnect in artemislib so
  that it can be configured to use this S3 bucket for scan data.
- Update IAM permssions in Terraform configuration so that the right
  things can read and write to the scans/ portion of the S3 bucket.
- Add sbom_dependency_migration utility to migrate the dependency trees
  from existing scans from the database to S3. This is useful for
  testing and also if there are key scans that need the performance
  improvement and can't wait for the scan replacement and cleanup
  process.

Unrelated to the SBOM dependency changes but included out of necessity:
- Pin urllib3 version to 1.x because of compatability issue with
  botocore: boto/botocore#2926
pizen added a commit to WarnerMedia/artemis that referenced this issue May 10, 2023
* Move dependency tree storage from the database to S3

Storing the SBOM dependency tree in the database turned out to not be the
right decision due to performance issues at scale. Previous changes to
improve performance reduced the usage of the dependency table to just
generating SBOM reports. This change moves the storage of the dependency
tree from the database to S3, removing the need to deconstruct and
reconstruct the tree and removes the overhead that goes along with that.
The S3 key is structured so that other SBOM file formats, such as SPDX
or CycloneDX, could also be stored alongside.

- Update engine SBOM processing to write the dependency tree to a JSON
  file in S3 instead of the database. The dependency tree is still
  processed in order to store component and license information in the
  database.
- Update sbom_report Lambda to pull the dependency tree JSON file from
  S3. If the file is not found in S3 it falls back to pulling the tree
  from the database. This allows for the gradual migration of the
  dependency tree data from the database to S3 as new scans are run and
  old scans are purged by the db_cleanup Lambda.
- Update the db_cleanup to identify and remove dependency files that
  were orphaned when their associated scans were deleted. Deleting scans
  via the ORM will clean up the dependency files from S3. This is a
  backstop just in case a scan is deleted directly or something else
  happens that prevents the cleanup at deletion time from succeeding.
- Update localstack config to add an S3 bucket that can store dependency
  tree files during local testing and update AWSConnect in artemislib so
  that it can be configured to use this S3 bucket for scan data.
- Update IAM permissions in Terraform configuration so that the right
  things can read and write to the scans/ portion of the S3 bucket.
- Add sbom_dependency_migration utility to migrate the dependency trees
  from existing scans from the database to S3. This is useful for
  testing and also if there are key scans that need the performance
  improvement and can't wait for the scan replacement and cleanup
  process.

Unrelated to the SBOM dependency changes but included out of necessity:
- Pin urllib3 version to 1.x because of compatibility issue with
  botocore: boto/botocore#2926
avelanarius pushed a commit to avelanarius/scylla-ccm that referenced this issue Jan 12, 2024
Look like new version of requests is pulling newer
versions of urllib3 which are not comptible with
botocore.

Ref: boto/botocore#2926
Ref: psf/requests#6443
Ref: urllib3/urllib3#2168
longhotsummer added a commit to laws-africa/indigo that referenced this issue Feb 1, 2024
zaro0508 added a commit to zaro0508/cfn-macro-ssm-param that referenced this issue Feb 1, 2024
We recently received the following error in the lambbda
cloudwatch logs..

```
Runtime.ImportModuleError: Unable to import module 'app':
cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_'
```

This seems like a library conflict between botocore and urllib3
so we update according to workaround proposed at these locations:

* https://stackoverflow.com/questions/76414514/cannot-import-name-default-ciphers-from-urllib3-util-ssl-on-aws-lambda-us
* boto/botocore#2926
* psf/requests#6432
zaro0508 added a commit to Sage-Bionetworks-IT/cfn-macro-ssm-param that referenced this issue Feb 2, 2024
We recently received the following error in the lambbda
cloudwatch logs..

```
Runtime.ImportModuleError: Unable to import module 'app':
cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_'
```

This seems like a library conflict between botocore and urllib3
so we update according to workaround proposed at these locations:

* https://stackoverflow.com/questions/76414514/cannot-import-name-default-ciphers-from-urllib3-util-ssl-on-aws-lambda-us
* boto/botocore#2926
* psf/requests#6432
@brodycj
Copy link

brodycj commented Feb 20, 2024

Is there anything we can do to help unblock an upgrade to a more recent version of urllib3, especially for those using Python 3.11 or 3.12?

@nateprewitt
Copy link
Contributor

Hi @brodybits, botocore currently supports urllib3<2.1 for Python 3.10+. There are some breaking changes in 2.1 (and more recently 2.2.0) that have prompted the current pinning. Once we have confidence we can safely move to the latest release, we'll look at updating the pin to catch up to the last couple months of releases.

@nateprewitt
Copy link
Contributor

Given we've resolved the 2.0 move on Python 3.10+ and don't have any immediate plans to add support for earlier versions, it's probably best to close this issue.

For tracking catching up to the latest minor release we can have a separate feature request, that will help with some of the confusion this thread has had in the last few months. Thanks everyone for your participation and patience!

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@SamStephens
Copy link

@nateprewitt can you please give us a link to the feature request for the update to urllib >= 2.1?

@brodycj
Copy link

brodycj commented Feb 20, 2024

@SamStephens I just filed #3138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies This issue is a problem in a dependency. feature-request This issue requests a feature. p2 This is a standard priority issue third-party
Projects
None yet
Development

No branches or pull requests