PynamoDB
PynamoDB copied to clipboard
ValueError: too many values to unpack on _resolve_endpoint_ruleset call
I have the following versions installed:
➜ pip freeze | grep -E "boto3|botocore|pynamodb"
boto3==1.34.66
botocore==1.34.66
pynamodb==5.4.0
And I get this error when calling .exists() on a Model class:
[...]
File "site-packages/pynamodb/models.py", line 762, in exists
cls._get_connection().describe_table()
File "site-packages/pynamodb/connection/table.py", line 294, in describe_table
return self.connection.describe_table(self.table_name)
File "site-packages/pynamodb/connection/base.py", line 791, in describe_table
data = self.dispatch(DESCRIBE_TABLE, operation_kwargs)
File "site-packages/pynamodb/connection/base.py", line 340, in dispatch
data = self._make_api_call(operation_name, operation_kwargs, settings)
File "site-packages/pynamodb/connection/base.py", line 376, in _make_api_call
endpoint_url, additional_headers = self.client._resolve_endpoint_ruleset(
ValueError: too many values to unpack (expected 2)
Updating to 5.5.1 fixed this issue for me.
opened PR to apply this fix to the 4.x version https://github.com/pynamodb/PynamoDB/pull/1235
I have a potentially naive follow up question. I ran into the same problem and found the same fix. What I'd love to understand is why the problem occurred in the first place. If the version of pynamodb I'm using didn't change, and the version of botocore didn't change, what did?
It appears that in cases where lambda/ecs/fargate (?) the underlying included boto3 may be used, and updated periodically.
It looks like in this case pynamodb is calling a private boto3 api, _resolve_endpoint_ruleset(). ._resolve_endpoint_ruleset() return signature changed causing pynamodb to crash. Or, if boto3/botocore are the same and you still get this issue, it could be that boto3/botocore where passing the raw response from an external API call.
Looking over the latest pynamodb.connections.base.py code it looks like usage of ._resolve_endpoint_ruleset() has been removed.
Just add these two lines in your dockerfile:
RUN rm -R /var/runtime/boto3
RUN rm -R /var/runtime/botocore