jbasko/autoboto

s3 get_bucket_location throws KeyError

Closed this issue · 1 comments

>>> s3.get_bucket_location(bucket='any_valid_bucket')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "autoboto/services/s3/client.py", line 818, in get_bucket_location
    return shapes.GetBucketLocationOutput.from_boto_dict(response)
  File "autoboto/core/shapes.py", line 150, in from_boto_dict
    return deserialise_from_boto(TypeInfo(cls), d)
  File "autoboto/core/shapes.py", line 48, in deserialise_from_boto
    attrs[attr_name] = deserialise_from_boto(attr_type, attr_value)
  File "autoboto/core/shapes.py", line 22, in deserialise_from_boto
    return type_info.type[payload]
  File "python3.7/enum.py", line 349, in __getitem__
    return cls._member_map_[name]
KeyError: 'us-east-2'

Thanks for reporting. This revealed two issues:

  1. Enum deserialisation was actually wrong and only worked when Enum value matched Enum name.
  2. Not all valid values are listed in botocore service metadata, so should allow raw values as inputs where Enums are expected -- "us-east-2" is not mentioned in https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/botocore/data/s3/2006-03-01/service-2.json#L1121

This is fixed in v0.3.0