Skip to content

httpsession.create_urllib3_context method has infinite recursion #3596

@mharish12

Description

@mharish12

Describe the issue

My requirements.txt

# Core FastAPI and Web Framework
fastapi==0.116.1
uvicorn==0.35.0
python-multipart==0.0.20
jinja2==3.1.6
starlette==0.47.3

# Database Dependencies
psycopg==3.2.9
psycopg2-binary==2.9.10
sqlalchemy==2.0.41
pymysql==1.1.1
sqlparse==0.4.4
sqlglot==27.4.1
psycopg-pool==3.2.7

# AI and ML Dependencies
#google-generativeai==0.8.5 #Removed as it is conflicting with langgraph
#google-ai-generativelanguage==0.6.15


## Langchain and Langgraph dependencies
langchain==1.0.5
langchain-community==0.4.1
langchain-classic==1.0.0
langchain-aws==1.0.0
langchain-core==1.0.4
#langchain-google-genai  # For Gemini support in LangGraph (optional)
langchain-google-vertexai==3.0.3 # Vertex AI integration
#langchain-openai==1.0.2  # For OpenAI support in LangGraph (optional)
langchain-text-splitters
langgraph==1.0.3
langgraph-checkpoint==3.0.1
langgraph-checkpoint-postgres==3.0.1
langchain-postgres==0.0.16
langgraph-checkpoint-sqlite==3.0.0
sentence-transformers==5.1.2
trustcall==0.0.39
langgraph-api==0.5.12
langgraph-cli==0.4.7
langgraph-prebuilt==1.0.2
chainlit==2.9.0
asyncpg==0.30.0
faiss-cpu==1.9.0.post1
boto3==1.40.19

botocore==1.40.19

# Data Processing
pandas==2.3.1
openpyxl==3.1.5
PyMuPDF==1.26.3
docx2txt==0.8
pdf2image==1.17.0

# Authentication and Security
python-jose==3.5.0
passlib==1.7.4

# Configuration and Utilities
python-dotenv==1.1.1
pydantic-settings==2.10.1
pydantic==2.12.3
requests==2.32.5
protobuf>=6.32.1
grpcio-tools==1.75.1

# Cache
redis==6.4.0

# Additional Dependencies
sql_metadata==2.17.0
google-cloud-aiplatform==1.126.1
google-cloud-storage>=3.5.0

# Kafka Dependencies
confluent-kafka==2.11.1

#openai
openai>=1.109.1
tiktoken==0.11.0

#ocr dependencies
pytesseract==0.3.13
pillow==11.3.0

#AWS MSK IAM authentication
aws-msk-iam-sasl-signer-python==1.0.2

matplotlib>=3.10.0
pyinstrument==5.0.0

#Confluence
atlassian-python-api==4.0.7
lxml==6.0.2
beautifulsoup4==4.14.2
markdownify==1.2.0

method: botocore.httpsession.create_urllib3_context

def _get_pool_manager_kwargs(self, **extra_kwargs):

def _get_ssl_context(self):
        return create_urllib3_context()

def create_urllib3_context(
    ssl_version=None, cert_reqs=None, options=None, ciphers=None
):
    """This function is a vendored version of the same function in urllib3

    We vendor this function to ensure that the SSL contexts we construct
    always use the std lib SSLContext instead of pyopenssl.
    """
    # PROTOCOL_TLS is deprecated in Python 3.10
    if not ssl_version or ssl_version == PROTOCOL_TLS:
        ssl_version = PROTOCOL_TLS_CLIENT

    context = SSLContext(ssl_version)

    if ciphers:
        context.set_ciphers(ciphers)
    elif DEFAULT_CIPHERS:
        context.set_ciphers(DEFAULT_CIPHERS)

    # Setting the default here, as we may have no ssl module on import
    cert_reqs = ssl.CERT_REQUIRED if cert_reqs is None else cert_reqs

    if options is None:
        options = 0
        # SSLv2 is easily broken and is considered harmful and dangerous
        options |= OP_NO_SSLv2
        # SSLv3 has several problems and is now dangerous
        options |= OP_NO_SSLv3
        # Disable compression to prevent CRIME attacks for OpenSSL 1.0+
        # (issue urllib3#309)
        options |= OP_NO_COMPRESSION
        # TLSv1.2 only. Unless set explicitly, do not request tickets.
        # This may save some bandwidth on wire, and although the ticket is encrypted,
        # there is a risk associated with it being on wire,
        # if the server is not rotating its ticketing keys properly.
        options |= OP_NO_TICKET

    context.options |= options ##Line causing the infinite recursion

how to reproduce

 session = boto3_module.Session(
                        aws_access_key_id='test',
                        aws_secret_access_key='test',
                        region_name="us-east-1"
                    )

                    client = session.client(
                        'dynamodb',
                        use_ssl=False,
                        endpoint_url=endpoint_url,
                        config=Config(
                            retries={'max_attempts': 0},
                            connect_timeout=5,
                            read_timeout=5
                        )
                    )

Error: RecursionError: maximum recursion depth exceeded

Links

Error: RecursionError: maximum recursion depth exceeded

I'm not sure it is an actual issue, if it not an issue,
how can I fix this error?

Metadata

Metadata

Assignees

Labels

p3This is a minor priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions