# Buggy code
def __init__(
    self,
    region=None,
    host=None,
    session_cls=None,
    request_timeout_seconds=None,
    max_retry_attempts=None,
    base_backoff_ms=None,
):
    self._tables = {}
    self.host = host
    self._session = None
    self._requests_session = None
    self._client = None
    if region:
        self.region = region
    else:
        self.region = get_settings_value("region")

    if session_cls:
        self.session_cls = session_cls
    else:
        self.session_cls = get_settings_value("session_cls")

    if request_timeout_seconds is not None:
        self._request_timeout_seconds = request_timeout_seconds
    else:
        self._request_timeout_seconds = get_settings_value("request_timeout_seconds")

    if max_retry_attempts is not None:
        self._max_retry_attempts_exception = max_retry_attempts
    else:
        self._max_retry_attempts_exception = get_settings_value("max_retry_attempts")

    if base_backoff_ms is not None:
        self._base_backoff_ms = base_backoff_ms
    else:
        self._base_backoff_ms = get_settings_value("base_backoff_ms")


# Traceback (KeyError)
Traceback (most recent call last):
File "./instrumentation/utils.py", line 69, in save_driver_log
driver_log.save()
File "/app/.heroku/python/lib/python2.7/site-packages/pynamodb/models.py", line 379, in save
data = self._get_connection().put_item(*args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/pynamodb/connection/table.py", line 83, in put_item
return_item_collection_metrics=return_item_collection_metrics)
File "/app/.heroku/python/lib/python2.7/site-packages/pynamodb/connection/base.py", line 806, in put_item
operation_kwargs.update(self.get_identifier_map(table_name, hash_key, range_key, key=ITEM))
File "/app/.heroku/python/lib/python2.7/site-packages/pynamodb/connection/base.py", line 648, in get_identifier_map
tbl = self.get_meta_table(table_name)
File "/app/.heroku/python/lib/python2.7/site-packages/pynamodb/connection/base.py", line 399, in get_meta_table
data = self.dispatch(DESCRIBE_TABLE, operation_kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/pynamodb/connection/base.py", line 235, in dispatch
data = self._make_api_call(operation_name, operation_kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/pynamodb/connection/base.py", line 250, in _make_api_call
operation_model = self.client._service_model.operation_model(operation_name)
File "/app/.heroku/python/lib/python2.7/site-packages/pynamodb/connection/base.py", line 387, in client
self._client = self.session.create_client(SERVICE_NAME, self.region, endpoint_url=self.host)
File "/app/.heroku/python/lib/python2.7/site-packages/botocore/session.py", line 809, in create_client
endpoint_resolver = self.get_component('endpoint_resolver')
File "/app/.heroku/python/lib/python2.7/site-packages/botocore/session.py", line 690, in get_component
return self._components.get_component(name)
File "/app/.heroku/python/lib/python2.7/site-packages/botocore/session.py", line 875, in get_component
del self._deferred[name]
KeyError: 'endpoint_resolver'

# Fixed code
def __init__(
    self,
    region=None,
    host=None,
    session_cls=None,
    request_timeout_seconds=None,
    max_retry_attempts=None,
    base_backoff_ms=None,
):
    self._tables = {}
    self.host = host
    self._local = local()
    self._requests_session = None
    self._client = None
    if region:
        self.region = region
    else:
        self.region = get_settings_value("region")

    if session_cls:
        self.session_cls = session_cls
    else:
        self.session_cls = get_settings_value("session_cls")

    if request_timeout_seconds is not None:
        self._request_timeout_seconds = request_timeout_seconds
    else:
        self._request_timeout_seconds = get_settings_value("request_timeout_seconds")

    if max_retry_attempts is not None:
        self._max_retry_attempts_exception = max_retry_attempts
    else:
        self._max_retry_attempts_exception = get_settings_value("max_retry_attempts")

    if base_backoff_ms is not None:
        self._base_backoff_ms = base_backoff_ms
    else:
        self._base_backoff_ms = get_settings_value("base_backoff_ms")