Fixed a bug where calling batch_get_item with non-existing tables names would not raise ResourceNotFoundException (#4344) (#4403)
This commit is contained in:
parent
9b5d42f7ef
commit
e8cd02617d
@ -486,9 +486,15 @@ class DynamoHandler(BaseResponse):
|
|||||||
|
|
||||||
results["Responses"][table_name] = []
|
results["Responses"][table_name] = []
|
||||||
for key in keys:
|
for key in keys:
|
||||||
item = self.dynamodb_backend.get_item(
|
try:
|
||||||
table_name, key, projection_expression
|
item = self.dynamodb_backend.get_item(
|
||||||
)
|
table_name, key, projection_expression
|
||||||
|
)
|
||||||
|
except ValueError:
|
||||||
|
return self.error(
|
||||||
|
"com.amazonaws.dynamodb.v20111205#ResourceNotFoundException",
|
||||||
|
"Requested resource not found",
|
||||||
|
)
|
||||||
if item:
|
if item:
|
||||||
item_describe = item.describe_attrs(attributes_to_get)
|
item_describe = item.describe_attrs(attributes_to_get)
|
||||||
results["Responses"][table_name].append(item_describe["Item"])
|
results["Responses"][table_name].append(item_describe["Item"])
|
||||||
|
@ -171,6 +171,18 @@ def test_update_item_range_key_set():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_dynamodb2
|
||||||
|
def test_batch_get_item_non_existing_table():
|
||||||
|
|
||||||
|
client = boto3.client("dynamodb", region_name="us-west-2")
|
||||||
|
|
||||||
|
with pytest.raises(client.exceptions.ResourceNotFoundException) as exc:
|
||||||
|
client.batch_get_item(RequestItems={"my-table": {"Keys": [{"id": {"N": "0"}}]}})
|
||||||
|
err = exc.value.response["Error"]
|
||||||
|
assert err["Code"].should.equal("ResourceNotFoundException")
|
||||||
|
assert err["Message"].should.equal("Requested resource not found")
|
||||||
|
|
||||||
|
|
||||||
@mock_dynamodb2
|
@mock_dynamodb2
|
||||||
def test_batch_write_item_non_existing_table():
|
def test_batch_write_item_non_existing_table():
|
||||||
client = boto3.client("dynamodb", region_name="us-west-2")
|
client = boto3.client("dynamodb", region_name="us-west-2")
|
||||||
|
Loading…
Reference in New Issue
Block a user