Skip to content

urllib3 2.6.x incompatibility: AttributeError: 'HTTPResponse' object has no attribute 'getheaders' (SDK calls removed API) #101

@eseifert

Description

@eseifert

Summary

With urllib3>=2.6.0, the Brevo/SendinBlue Python client fails at runtime with:

AttributeError: 'HTTPResponse' object has no attribute 'getheaders'

This happens when ApiException is raised and the SDK calls http_resp.getheaders().

Evidence / references

Reproduction

pip install "sib-api-v3-sdk==7.6.0" "urllib3>=2.6.0"

Trigger any API error (401/403/etc.) so the SDK raises ApiException, e.g. invalid API key:

import sib_api_v3_sdk
from sib_api_v3_sdk.rest import ApiException

cfg = sib_api_v3_sdk.Configuration()
cfg.api_key["api-key"] = "invalid"

api = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(cfg))

try:
    api.get_smtp_templates()
except ApiException as e:
    print("caught:", e)

Proposed fix (backwards compatible)

Update the SDK response wrapper to use .headers when getheaders() / getheader() are not available:

# sib_api_v3_sdk/rest.py

def getheaders(self):
    if hasattr(self.urllib3_response, "getheaders"):
        return self.urllib3_response.getheaders()
    return self.urllib3_response.headers

def getheader(self, name, default=None):
    if hasattr(self.urllib3_response, "getheader"):
        return self.urllib3_response.getheader(name, default)
    return self.urllib3_response.headers.get(name, default)

Workaround

Pin urllib3 until the SDK is regenerated/fixed:

urllib3<2.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions