Repository navigation
fix(ec2): a volume or AMI ID that names nothing is an error (#731) - #742
Merged
Merged
Conversation
DescribeVolumes and DescribeImages answered 200 and an empty set for an ID that resolved to nothing, so a consumer's InvalidVolume.NotFound branch was unreachable and a poll loop could not tell "not yet" from "never". Both now route their ID lists through the same ec2IDFilter the other ten ID-asserting describes use, so the codes, messages, status and the syntax-before-absence ordering come from one table. DescribeImages was worse than the issue reported: it read no ImageId.N at all, so a caller naming one AMI was answered with every AMI the account owned. A superset is invisible where an error is not. DescribeVolumes' hand-rolled loop had two more silent widenings — it ignored the un-indexed VolumeId form, and it stopped at the first empty value rather than the first missing key, discarding every ID after an empty one. A bundled public AMI (#733) is nameable here though still not enumerated: a describe that called an AMI absent while a launch accepted it would contradict itself.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #731.
DescribeVolumesandDescribeImagesanswered 200 and an empty set for an ID thatresolved to nothing. Both now route their ID lists through
ec2IDFilter, the helper theother ten ID-asserting describes already share, so they answer
InvalidVolume.NotFound/InvalidVolumeID.MalformedandInvalidAMIID.NotFound/InvalidAMIID.Malformedfrom the one kind table — syntax beforeabsence, one present plus one absent failing the whole call, and an ID a
Filterexcludedstill counting as resolved. Twelve EC2 describes now assert existence.
What the survey found beyond the issue
DescribeImagesread noImageId.Nat all — a caller naming one AMI was answeredwith every AMI the account owned. This is the worse half: an error is visible, a superset
reads as a successful narrowing, so "the query returns only my AMI" passed with the other
AMI in the assertion's blind spot.
DescribeVolumes' hand-rolled loop had two more silent widenings. It read only theindexed
VolumeId.N, ignoring the un-indexedVolumeIda hand-built request or an olderSDK shape sends; and it stopped at the first empty value rather than the first missing
key, so an explicitly empty
VolumeId.1discardedVolumeId.2and everything afterit.
extractIndexedParamsfixes both, and an empty value is nowMalformed— it is anID the caller sent.
validate()moved ahead of the filter-name check onDescribeVolumes, where it ransecond, matching all ten existing handlers.
TestEC2_IDListValidatesBeforeFilterNamespins the ordering, which nothing did.
The
DescribeImageshalf inheritsec2ImageIDKindfrom #733 (PR #741) rather than addinga kind — same table, same wording, same ordering as the volume half.
Two decisions recorded rather than implemented
A bundled public AMI is nameable here, though still not enumerated. A describe that
called an AMI absent while a launch accepted it would contradict itself, and resolving an
AMI through SSM and then reading its members is the workflow generated IaC produces. So a
named bundled ID resolves through a second pass over
resolveImageand renders the samemembers a registered AMI does, while an unqualified
DescribeImagesstill lists only whatthe account owns.
Owner.NandExecutableBy.Nstay unread, now stated in the docs with the reason:substrate stores only images the account owns, so
selfis the answer to every describeand AWS's other three
Ownervalues select sets substrate does not model. Reading theparameter would let a caller believe a narrowing happened.
Corrections in passing
containsStr's doc comment claimedKeyName.N,GroupName.N,FleetId.NandRegionName.Neach raise anInvalid*.NotFoundon an unmatched entry; onlyInstanceType.Ndoes.docs/services.mdcounted "six of the new selectors" answering anempty set where AWS answers
NotFoundand named four families; there are seven, and thenew Which selectors assert existence subsection gives each its reason — separating
DescribeFleets'FleetId.NandDescribeRegions'RegionName.N, which are permanentdeclines, from the five that are merely unimplemented.
Compatibility
A describe naming a volume or an AMI that does not exist now fails where it returned an
empty set. Two of substrate's own tests asserted the empty set as the contract — one with a
comment naming this exact gap — and both now assert the refusal.
Verification
gofmt/go build/go vet/golangci-lintclean;make test(race) green; emulatorcoverage 83.3%, total 82.6%;
make docs-reference-check docs-versionsclean; VitePressbuild clean with no dangling anchors;
go vet/go testclean intest/e2e.Thirteen live
awsCLI checks against a built binary on:4678, including the issue's owncommand:
and the round trip the two halves have to agree on:
ssm get-parameterresolvesami-d4c4e839d3f47ba84,describe-images --image-idsanswers with it, an unqualifieddescribe-imagesdoes not list it, andrun-instanceslaunches it.