Repository navigation
Description
Summary
ec2:Describe* calls that filter by explicit resource ID return 200 with an empty
list when the ID does not exist. Real EC2 raises a Client.Invalid<Type>ID.NotFound
error. It also accepts syntactically invalid IDs, where real EC2 raises
Invalid<Type>ID.Malformed.
This is the "absent vs. filtered" distinction: describe_vpcs() with no arguments
legitimately returns [], but describe_vpcs(VpcIds=["vpc-dead"]) is an assertion
that the ID exists, and EC2 answers it with an error.
Reproduction
Against ghcr.io/scttfrdmn/substrate:0.76.0:
ec2 = boto3.client("ec2", endpoint_url="http://localhost:4566", region_name="us-east-1")
ec2.describe_vpcs(VpcIds=["vpc-0000000000000dead"]) # -> 200 {"Vpcs": []}
ec2.describe_subnets(SubnetIds=["subnet-0000000000000dead"]) # -> 200 {"Subnets": []}
ec2.describe_security_groups(GroupIds=["sg-0000000000000dead"]) # -> 200 {"SecurityGroups": []}
ec2.describe_instances(InstanceIds=["i-0000000000000dead"]) # -> 200 {"Reservations": []}
ec2.describe_vpcs(VpcIds=["not-an-id"]) # -> 200 {"Vpcs": []}Expected
| Call | AWS error code |
|---|---|
describe_vpcs(VpcIds=[missing]) |
InvalidVpcID.NotFound |
describe_subnets(SubnetIds=[missing]) |
InvalidSubnetID.NotFound |
describe_security_groups(GroupIds=[missing]) |
InvalidGroup.NotFound |
describe_instances(InstanceIds=[missing]) |
InvalidInstanceID.NotFound |
describe_vpcs(VpcIds=["not-an-id"]) |
InvalidVpcID.Malformed |
Note AWS's inconsistent casing, which is worth mirroring exactly: InvalidVpcID
and InvalidSubnetID but InvalidGroupId.Malformed (lowercase d) and
InvalidGroup.NotFound (no Id at all).
Why it matters
This makes a whole class of validation logic untestable rather than merely
differently-shaped. A concrete case from parsl-ephemeral-aws, whose entire
network-precondition check is built on these codes:
try:
ec2.describe_vpcs(VpcIds=[self.vpc_id])
except ClientError as e:
if e.response["Error"]["Code"] in ("InvalidVpcID.NotFound", "InvalidVpcID.Malformed"):
raise ResourceNotFoundError(f"vpc_id {self.vpc_id} is not usable ...")Against substrate this code path is unreachable: the call succeeds, the guard is
skipped, and a test asserting "a deleted VPC is reported clearly" passes while
verifying nothing. describe_instances returning [] instead of raising is the
same hazard in status-polling loops, which commonly read
Reservations[0]["Instances"][0] and would get IndexError instead of the
InvalidInstanceID.NotFound they handle.
Emulators that return success where AWS errors are worse than ones that are merely
incomplete, because the test suite reports green.
Activity
fix(ec2): raise Invalid*.NotFound/Malformed for explicit resource IDs (…
chore(release): v0.80.0 (#423)