Skip to content

fix(ec2): a volume or AMI ID that names nothing is an error (#731) - #742

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/731-describe-id-assertions
Aug 22, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/731-describe-id-assertions

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #731.

DescribeVolumes and DescribeImages answered 200 and an empty set for an ID that
resolved to nothing. Both now route their ID lists through ec2IDFilter, the helper the
other ten ID-asserting describes already share, so they answer
InvalidVolume.NotFound/InvalidVolumeID.Malformed and
InvalidAMIID.NotFound/InvalidAMIID.Malformed from the one kind table — syntax before
absence, one present plus one absent failing the whole call, and an ID a Filter excluded
still counting as resolved. Twelve EC2 describes now assert existence.

What the survey found beyond the issue

  • DescribeImages read no ImageId.N at all — a caller naming one AMI was answered
    with 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 the
    indexed VolumeId.N, ignoring the un-indexed VolumeId a hand-built request or an older
    SDK shape sends; and it stopped at the first empty value rather than the first missing
    key, so an explicitly empty VolumeId.1 discarded VolumeId.2 and everything after
    it. extractIndexedParams fixes both, and an empty value is now Malformed — it is an
    ID the caller sent.
  • validate() moved ahead of the filter-name check on DescribeVolumes, where it ran
    second, matching all ten existing handlers. TestEC2_IDListValidatesBeforeFilterNames
    pins the ordering, which nothing did.

The DescribeImages half inherits ec2ImageIDKind from #733 (PR #741) rather than adding
a 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 resolveImage and renders the same
members a registered AMI does, while an unqualified DescribeImages still lists only what
the account owns.

Owner.N and ExecutableBy.N stay unread, now stated in the docs with the reason:
substrate stores only images the account owns, so self is the answer to every describe
and AWS's other three Owner values select sets substrate does not model. Reading the
parameter would let a caller believe a narrowing happened.

Corrections in passing

containsStr's doc comment claimed KeyName.N, GroupName.N, FleetId.N and
RegionName.N each raise an Invalid*.NotFound on an unmatched entry; only
InstanceType.N does. docs/services.md counted "six of the new selectors" answering an
empty set where AWS answers NotFound and named four families; there are seven, and the
new Which selectors assert existence subsection gives each its reason — separating
DescribeFleets' FleetId.N and DescribeRegions' RegionName.N, which are permanent
declines, 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-lint clean; make test (race) green; emulator
coverage 83.3%, total 82.6%; make docs-reference-check docs-versions clean; VitePress
build clean with no dangling anchors; go vet/go test clean in test/e2e.

Thirteen live aws CLI checks against a built binary on :4678, including the issue's own
command:

$ aws ec2 describe-volumes --volume-ids vol-0aaaaaaaaaaaaaaaa
InvalidVolume.NotFound: The volume ID 'vol-0aaaaaaaaaaaaaaaa' does not exist
$ aws ec2 describe-volumes --volume-ids vol-0000000000000dead nope
InvalidVolumeID.Malformed: Invalid id: "nope"
$ aws ec2 describe-images --image-ids ami-EXAMPLE
InvalidAMIID.Malformed: Invalid id: "ami-EXAMPLE"

and the round trip the two halves have to agree on: ssm get-parameter resolves
ami-d4c4e839d3f47ba84, describe-images --image-ids answers with it, an unqualified
describe-images does not list it, and run-instances launches it.

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.
@scttfrdmn
scttfrdmn merged commit 140fd4e into main Aug 22, 2026
15 checks passed
@scttfrdmn
scttfrdmn deleted the fix/731-describe-id-assertions branch August 22, 2026 18:49
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.36364% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/ec2_plugin.go 84.21% 3 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ec2: DescribeVolumes answers an unknown VolumeId with an empty set, not InvalidVolume.NotFound

1 participant