boto3 icon indicating copy to clipboard operation
boto3 copied to clipboard

Getting a http error

Open JamesNSmith opened this issue 9 months ago • 2 comments

Describe the bug

Not able to use boto3, getting an error:

Error: An HTTP Client raised an unhandled exception: 'NoneType' object has no attribute 'get'

Regression Issue

  • [ ] Select this option if this issue appears to be a regression.

Expected Behavior

There should not be a http error.

Current Behavior

Produces the error:

Error: An HTTP Client raised an unhandled exception: 'NoneType' object has no attribute 'get'

Reproduction Steps

import boto3

if __name__ == "__main__":

    try:
        session = boto3.Session()
        client = session.client("secretsmanager", region_name="eu-west-1")

        print("Getting secret")
        print(client)

        secret = client.list_secrets()

        print("Secret listed successfully")

        print(secret)

    except Exception as e:
        print(f"Error: {e}")

Produces: Getting secret <botocore.client.SecretsManager object at 0x102cfda00> Error: An HTTP Client raised an unhandled exception: 'NoneType' object has no attribute 'get'

Possible Solution

No response

Additional Information/Context

Only able to reproduce on the problem device. I assume it is a problem with something that boto3 / botocore depends on, but not sure. The AWS CLI is able to list the secrets as expected.

SDK version used

1.37.2

Environment details (OS name and version, etc.)

Mac Python 3.9.13

JamesNSmith avatar Mar 28 '25 12:03 JamesNSmith

Hello @JamesNSmith, thanks for reaching out. I have tried to replicate with your code above with the same environment and version and I did not get any issues. Could you please provide the full debug logs by adding boto3.set_stream_logger('') to your code and redacting any sensitive information? Also, if you could upgrade to a newer boto version pip install --upgrade boto3 https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html. Please let me know if you have any questions. Thanks.

adev-code avatar May 14 '25 20:05 adev-code

Hi

Thanks for investigating the issue.

This is what I get:

2025-05-19 14:26:14,174 botocore.hooks [DEBUG] Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane 2025-05-19 14:26:14,175 botocore.hooks [DEBUG] Changing event name from before-call.apigateway to before-call.api-gateway 2025-05-19 14:26:14,175 botocore.hooks [DEBUG] Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict 2025-05-19 14:26:14,175 botocore.hooks [DEBUG] Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration 2025-05-19 14:26:14,175 botocore.hooks [DEBUG] Changing event name from before-parameter-build.route53 to before-parameter-build.route-53 2025-05-19 14:26:14,176 botocore.hooks [DEBUG] Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search 2025-05-19 14:26:14,176 botocore.hooks [DEBUG] Changing event name from docs..autoscaling.CreateLaunchConfiguration.complete-section to docs..auto-scaling.CreateLaunchConfiguration.complete-section 2025-05-19 14:26:14,177 botocore.hooks [DEBUG] Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask 2025-05-19 14:26:14,177 botocore.hooks [DEBUG] Changing event name from docs..logs.CreateExportTask.complete-section to docs..cloudwatch-logs.CreateExportTask.complete-section 2025-05-19 14:26:14,177 botocore.hooks [DEBUG] Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search 2025-05-19 14:26:14,177 botocore.hooks [DEBUG] Changing event name from docs..cloudsearchdomain.Search.complete-section to docs..cloudsearch-domain.Search.complete-section 2025-05-19 14:26:14,181 botocore.utils [DEBUG] IMDS ENDPOINT: http://169.254.169.254/ 2025-05-19 14:26:14,186 botocore.credentials [DEBUG] Looking for credentials via: env 2025-05-19 14:26:14,186 botocore.credentials [DEBUG] Looking for credentials via: assume-role 2025-05-19 14:26:14,186 botocore.credentials [DEBUG] Looking for credentials via: assume-role-with-web-identity 2025-05-19 14:26:14,186 botocore.credentials [DEBUG] Looking for credentials via: sso 2025-05-19 14:26:14,187 botocore.loaders [DEBUG] Loading JSON file: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/data/endpoints.json 2025-05-19 14:26:14,196 botocore.loaders [DEBUG] Loading JSON file: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/data/sdk-default-configuration.json 2025-05-19 14:26:14,196 botocore.hooks [DEBUG] Event choose-service-name: calling handler <function handle_service_name_alias at 0x104750b80> 2025-05-19 14:26:14,209 botocore.loaders [DEBUG] Loading JSON file: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/data/secretsmanager/2017-10-17/service-2.json.gz 2025-05-19 14:26:14,210 botocore.loaders [DEBUG] Loading JSON file: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/data/secretsmanager/2017-10-17/service-2.sdk-extras.json 2025-05-19 14:26:14,220 botocore.loaders [DEBUG] Loading JSON file: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/data/secretsmanager/2017-10-17/endpoint-rule-set-1.json.gz 2025-05-19 14:26:14,220 botocore.loaders [DEBUG] Loading JSON file: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/data/partitions.json 2025-05-19 14:26:14,220 botocore.hooks [DEBUG] Event creating-client-class.secrets-manager: calling handler <function add_generate_presigned_url at 0x104725550> 2025-05-19 14:26:14,220 botocore.configprovider [DEBUG] Looking for endpoint for secretsmanager via: environment_service 2025-05-19 14:26:14,220 botocore.configprovider [DEBUG] Looking for endpoint for secretsmanager via: environment_global 2025-05-19 14:26:14,220 botocore.configprovider [DEBUG] Looking for endpoint for secretsmanager via: config_service 2025-05-19 14:26:14,220 botocore.configprovider [DEBUG] Looking for endpoint for secretsmanager via: config_global 2025-05-19 14:26:14,220 botocore.configprovider [DEBUG] No configured endpoint found. 2025-05-19 14:26:14,240 botocore.endpoint [DEBUG] Setting secretsmanager timeout as (60, 60) 2025-05-19 14:26:14,241 botocore.loaders [DEBUG] Loading JSON file: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/data/_retry.json 2025-05-19 14:26:14,248 botocore.client [DEBUG] Registering retry handlers for service: secretsmanager Getting secret <botocore.client.SecretsManager object at 0x10471d1f0> 2025-05-19 14:26:14,248 botocore.hooks [DEBUG] Event before-parameter-build.secrets-manager.ListSecrets: calling handler <function generate_idempotent_uuid at 0x1047c04c0> 2025-05-19 14:26:14,248 botocore.hooks [DEBUG] Event before-parameter-build.secrets-manager.ListSecrets: calling handler <function _handle_request_validation_mode_member at 0x1047d5ca0> 2025-05-19 14:26:14,248 botocore.regions [DEBUG] Calling endpoint provider with parameters: {'Region': 'eu-west-1', 'UseDualStack': False, 'UseFIPS': False} 2025-05-19 14:26:14,248 botocore.regions [DEBUG] Endpoint provider result: https://secretsmanager.eu-west-1.amazonaws.com 2025-05-19 14:26:14,248 botocore.hooks [DEBUG] Event before-call.secrets-manager.ListSecrets: calling handler <function add_recursion_detection_header at 0x1047c00d0> 2025-05-19 14:26:14,248 botocore.hooks [DEBUG] Event before-call.secrets-manager.ListSecrets: calling handler <function add_query_compatibility_header at 0x1047d5c10> 2025-05-19 14:26:14,248 botocore.hooks [DEBUG] Event before-call.secrets-manager.ListSecrets: calling handler <function inject_api_version_header_if_needed at 0x1047c6d30> 2025-05-19 14:26:14,248 botocore.endpoint [DEBUG] Making request for OperationModel(name=ListSecrets) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'secretsmanager.ListSecrets', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'Boto3/1.38.18 md/Botocore#1.38.18 ua/2.1 os/macos#24.4.0 md/arch#arm64 lang/python#3.9.13 md/pyimpl#CPython m/b,Z cfg/retry-mode#legacy Botocore/1.38.18'}, 'body': b'{}', 'url': 'https://secretsmanager.eu-west-1.amazonaws.com/', 'context': {'client_region': 'eu-west-1', 'client_config': <botocore.config.Config object at 0x10471d310>, 'has_streaming_input': False, 'auth_type': None, 'unsigned_payload': None}} 2025-05-19 14:26:14,249 botocore.hooks [DEBUG] Event request-created.secrets-manager.ListSecrets: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x10471d5e0>> 2025-05-19 14:26:14,249 botocore.hooks [DEBUG] Event choose-signer.secrets-manager.ListSecrets: calling handler <function set_operation_specific_signer at 0x1047c0310> 2025-05-19 14:26:14,249 botocore.hooks [DEBUG] Event choose-service-name: calling handler <function handle_service_name_alias at 0x104750b80> 2025-05-19 14:26:14,249 botocore.loaders [DEBUG] Loading JSON file: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/data/sso/2019-06-10/service-2.json.gz 2025-05-19 14:26:14,249 botocore.loaders [DEBUG] Loading JSON file: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/data/sso/2019-06-10/endpoint-rule-set-1.json.gz 2025-05-19 14:26:14,250 botocore.hooks [DEBUG] Event creating-client-class.sso: calling handler <function add_generate_presigned_url at 0x104725550> 2025-05-19 14:26:14,250 botocore.configprovider [DEBUG] Looking for endpoint for sso via: environment_service 2025-05-19 14:26:14,250 botocore.configprovider [DEBUG] Looking for endpoint for sso via: environment_global 2025-05-19 14:26:14,250 botocore.configprovider [DEBUG] Looking for endpoint for sso via: config_service 2025-05-19 14:26:14,250 botocore.configprovider [DEBUG] Looking for endpoint for sso via: config_global 2025-05-19 14:26:14,250 botocore.configprovider [DEBUG] No configured endpoint found. 2025-05-19 14:26:14,269 botocore.endpoint [DEBUG] Setting portal.sso timeout as (60, 60) 2025-05-19 14:26:14,269 botocore.client [DEBUG] Registering retry handlers for service: sso 2025-05-19 14:26:14,270 botocore.tokens [INFO] Loading cached SSO token for Pimberly 2025-05-19 14:26:14,270 botocore.utils [DEBUG] Checking for cached token at: a546b499ba9724e21ab266836612ecf89e843571 2025-05-19 14:26:14,271 botocore.tokens [DEBUG] Cached SSO token expires at 2025-05-19 14:13:45+00:00 2025-05-19 14:26:14,271 botocore.hooks [DEBUG] Event before-parameter-build.sso.GetRoleCredentials: calling handler <function generate_idempotent_uuid at 0x1047c04c0> 2025-05-19 14:26:14,271 botocore.hooks [DEBUG] Event before-parameter-build.sso.GetRoleCredentials: calling handler <function _handle_request_validation_mode_member at 0x1047d5ca0> 2025-05-19 14:26:14,271 botocore.regions [DEBUG] Calling endpoint provider with parameters: {'Region': 'eu-west-1', 'UseDualStack': False, 'UseFIPS': False} 2025-05-19 14:26:14,271 botocore.regions [DEBUG] Endpoint provider result: https://portal.sso.eu-west-1.amazonaws.com 2025-05-19 14:26:14,272 botocore.hooks [DEBUG] Event before-call.sso.GetRoleCredentials: calling handler <function add_recursion_detection_header at 0x1047c00d0> 2025-05-19 14:26:14,272 botocore.hooks [DEBUG] Event before-call.sso.GetRoleCredentials: calling handler <function add_query_compatibility_header at 0x1047d5c10> 2025-05-19 14:26:14,272 botocore.hooks [DEBUG] Event before-call.sso.GetRoleCredentials: calling handler <function inject_api_version_header_if_needed at 0x1047c6d30> 2025-05-19 14:26:14,272 botocore.endpoint [DEBUG] Making request for OperationModel(name=GetRoleCredentials) with params: {'url_path': '/federation/credentials', 'query_string': {'role_name': 'pimberlyEngineering', 'account_id': '779846821245'}, 'method': 'GET', 'headers': {'x-amz-sso_bearer_token': '', 'User-Agent': 'Boto3/1.38.18 md/Botocore#1.38.18 ua/2.1 os/macos#24.4.0 md/arch#arm64 lang/python#3.9.13 md/pyimpl#CPython m/b,Z cfg/retry-mode#legacy Botocore/1.38.18'}, 'body': b'', 'url': 'https://portal.sso.eu-west-1.amazonaws.com/federation/credentials?role_name=pimberlyEngineering&account_id=779846821245', 'context': {'client_region': 'eu-west-1', 'client_config': <botocore.config.Config object at 0x1046f2430>, 'has_streaming_input': False, 'auth_type': 'none', 'unsigned_payload': None}} 2025-05-19 14:26:14,272 botocore.hooks [DEBUG] Event request-created.sso.GetRoleCredentials: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x1046f2250>> 2025-05-19 14:26:14,272 botocore.hooks [DEBUG] Event choose-signer.sso.GetRoleCredentials: calling handler <function set_operation_specific_signer at 0x1047c0310> 2025-05-19 14:26:14,272 botocore.hooks [DEBUG] Event request-created.sso.GetRoleCredentials: calling handler <bound method UserAgentString.rebuild_and_replace_user_agent_handler of <botocore.useragent.UserAgentString object at 0x1046e7dc0>> 2025-05-19 14:26:14,272 botocore.hooks [DEBUG] Event request-created.sso.GetRoleCredentials: calling handler <function add_retry_headers at 0x1047d5550> 2025-05-19 14:26:14,272 botocore.endpoint [DEBUG] Sending http request: <AWSPreparedRequest stream_output=False, method=GET, url=https://portal.sso.eu-west-1.amazonaws.com/federation/credentials?role_name=pimberlyEngineering&account_id=779846821245, headers={'x-amz-sso_bearer_token': b'', 'User-Agent': b'Boto3/1.38.18 md/Botocore#1.38.18 ua/2.1 os/macos#24.4.0 md/arch#arm64 lang/python#3.9.13 md/pyimpl#CPython m/b,Z cfg/retry-mode#legacy Botocore/1.38.18', 'amz-sdk-invocation-id': b'003b8a39-93a6-477a-b9c8-7b3da8b552e7', 'amz-sdk-request': b'attempt=1'}> 2025-05-19 14:26:14,272 botocore.httpsession [DEBUG] Certificate path: /Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/certifi/cacert.pem 2025-05-19 14:26:14,273 urllib3.connectionpool [DEBUG] Starting new HTTPS connection (1): portal.sso.eu-west-1.amazonaws.com:443 2025-05-19 14:26:14,323 botocore.httpsession [DEBUG] Exception received when sending urllib3 HTTP request Traceback (most recent call last): File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/httpsession.py", line 464, in send urllib_response = conn.urlopen( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 716, in urlopen httplib_response = self._make_request( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 404, in _make_request self._validate_conn(conn) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1061, in _validate_conn conn.connect() File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/urllib3/connection.py", line 462, in connect if not cert.get("subjectAltName", ()): AttributeError: 'NoneType' object has no attribute 'get' 2025-05-19 14:26:14,324 botocore.hooks [DEBUG] Event needs-retry.sso.GetRoleCredentials: calling handler <botocore.retryhandler.RetryHandler object at 0x1046da310> 2025-05-19 14:26:14,324 botocore.credentials [WARNING] Refreshing temporary credentials failed during mandatory refresh period. Traceback (most recent call last): File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/httpsession.py", line 464, in send urllib_response = conn.urlopen( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 716, in urlopen httplib_response = self._make_request( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 404, in _make_request self._validate_conn(conn) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1061, in _validate_conn conn.connect() File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/urllib3/connection.py", line 462, in connect if not cert.get("subjectAltName", ()): AttributeError: 'NoneType' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/credentials.py", line 567, in _protected_refresh metadata = self._refresh_using() File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/credentials.py", line 716, in fetch_credentials return self._get_cached_credentials() File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/credentials.py", line 726, in _get_cached_credentials response = self._get_credentials() File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/credentials.py", line 2253, in _get_credentials response = client.get_role_credentials(**kwargs) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/client.py", line 595, in _api_call return self._make_api_call(operation_name, kwargs) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/context.py", line 123, in wrapper return func(*args, **kwargs) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/client.py", line 1040, in _make_api_call http, parsed_response = self._make_request( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/client.py", line 1064, in _make_request return self._endpoint.make_request(operation_model, request_dict) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/endpoint.py", line 119, in make_request return self._send_request(request_dict, operation_model) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/endpoint.py", line 200, in _send_request while self._needs_retry( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/endpoint.py", line 360, in _needs_retry responses = self._event_emitter.emit( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/hooks.py", line 412, in emit return self._emitter.emit(aliased_event_name, **kwargs) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/hooks.py", line 256, in emit return self._emit(event_name, kwargs) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/hooks.py", line 239, in _emit response = handler(**kwargs) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/retryhandler.py", line 207, in call if self._checker(**checker_kwargs): File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/retryhandler.py", line 284, in call should_retry = self._should_retry( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/retryhandler.py", line 307, in _should_retry return self._checker( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/retryhandler.py", line 363, in call checker_response = checker( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/retryhandler.py", line 247, in call return self._check_caught_exception( File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/retryhandler.py", line 416, in _check_caught_exception raise caught_exception File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/endpoint.py", line 279, in _do_get_response http_response = self._send(request) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/endpoint.py", line 383, in _send return self.http_session.send(request) File "/Users/david/src/custom-integration-scripts-latest/.venv/lib/python3.9/site-packages/botocore/httpsession.py", line 509, in send raise HTTPClientError(error=e) botocore.exceptions.HTTPClientError: An HTTP Client raised an unhandled exception: 'NoneType' object has no attribute 'get' Error: An HTTP Client raised an unhandled exception: 'NoneType' object has no attribute 'get'

JamesNSmith avatar May 19 '25 13:05 JamesNSmith

Reproing the issue:

import boto3

boto3.set_stream_logger('')

session = boto3.Session()
client = session.client("secretsmanager", region_name="eu-west-1")
print("Getting secret")
print(client)
secret = client.list_secrets()

print("Secret listed successfully")
print(secret)

'User-Agent': 'Boto3/1.40.33 md/Botocore#1.40.33

I did not get HTTP error and the service listed. Could you retry again and see if you are still seeing the issue?

adev-code avatar Sep 18 '25 18:09 adev-code

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.

github-actions[bot] avatar Sep 26 '25 21:09 github-actions[bot]