Skip to content

feat(ec2): a filter spec per never-parsed describe (#695) - #722

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/695-filter-spec-per-describe
Aug 22, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/695-filter-spec-per-describe

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #695

Twelve EC2 describes declared a Filters parameter on their reference page and never parsed
one: DescribeInstanceStatus, DescribeVpcs, DescribeInternetGateways, DescribeKeyPairs,
DescribeAvailabilityZones, DescribePlacementGroups, DescribeAddresses, DescribeRegions,
DescribeInstanceTypes, DescribeSpotPriceHistory, DescribeLaunchTemplates and
DescribeLaunchTemplateVersions. A filter reached the handler and was discarded, so a request
for one VPC by cidr answered with every VPC in the account.

With this, twenty-three of the twenty-four EC2 describes substrate serves parse Filter.N.
The exception is DescribeInstanceAttribute, whose page documents no Filters parameter at all.

Correction to the issue

#695 says fourteen describes never parse Filter.N. It is twelve: DescribeSubnets
landed in #685 and DescribeTags in #688, and DescribeInstanceAttribute documents no
Filters parameter and is excluded rather than fixed.

Evaluated, or accepted and inert

Three of the twelve evaluate every name their page documents — DescribeInternetGateways
(6/6), DescribeRegions (3/3), DescribeLaunchTemplates (4/4). The rest evaluate what
substrate's records can answer and accept the remainder as inert, each inert name listed per
operation in docs/services.md. An undocumented name is refused with
InvalidParameterValue, per #687.

That split is what closes TODO(#495) on DescribeInstanceTypes. #495's objection to applying
five of fifty-seven filters was never the five — it was that dropping the fifty-two silently
is indistinguishable from applying them. Naming every inert one resolves that; the code no
longer contradicts its own doc comment, which claimed Filter.N was unapplied directly above a
line applying it.

Eight of the twelve document no tag filter, which is why the choice is per operation.
DescribeLaunchTemplates documents both tag:<key> and tag-key while
DescribeLaunchTemplateVersions, on the same page family, documents neither.

Wire changes a consumer should know about

  • DescribeVpcs/CreateVpc name the state element state, not vpcState — both of AWS's
    samples render <state>available</state>.
  • Seven response members appear where they were absent, each because a filter now selects on
    it: ownerId and tagSet on a VPC; ownerId, attachmentSet and tagSet on an internet
    gateway; groupArn on a placement group; tagSet on an address; availabilityZone on an
    instance status.
  • The empty-value convention follows each page rather than a house style: an internet gateway
    renders <attachmentSet/> and <tagSet/> when empty because its sample does; a VPC and an
    address omit tagSet because theirs do.
  • DescribeLaunchTemplateVersions filters before it paginates.
  • Fixed: LaunchTemplateId.N, LaunchTemplateName.N and ProductDescription.N were read at
    index 1 only, so a caller naming three templates was answered about one.

The CreateVpc/DescribeVpcs and CreateInternetGateway/DescribeInternetGateways renderers
were separate structs that had drifted; each pair now emits one shape by construction. Two tests
pin that, and both were vacuous until they asserted the members present — equality alone was
satisfied by the two responses being equally blank, which is exactly what they were before.

Provenance

  • A paired identity list is a union, not an intersection, and AWS documents no rule. Five
    operations take one: KeyName.N/KeyPairId.N, ZoneName.N/ZoneId.N,
    GroupName.N/GroupId.N, AllocationId.N/PublicIp.N,
    LaunchTemplateId.N/LaunchTemplateName.N. The reading comes from what AWS does document:
    an unresolvable name or ID answers NotFound rather than an empty set, which only makes sense
    if every identifier named is expected in the response — and an intersection would answer
    nothing for two identifiers that each resolve.
  • Six new selectors answer an empty set where AWS answers NotFound — KeyName.N,
    KeyPairId.N, GroupName.N/GroupId.N on placement groups, ZoneName.N/ZoneId.N,
    PublicIp.N. Stated as a gap in the docs rather than papered over.
  • Refusing an undocumented filter name is observed, not documented — the carried-forward
    provenance of ec2: three inconsistent unknown-filter-name behaviours, where real AWS refuses #687.
  • No pagination was added. Four of the twelve (DescribeAddresses, DescribeKeyPairs,
    DescribeAvailabilityZones, DescribePlacementGroups) publish no MaxResults/NextToken.
  • Also left standing, and named in the docs: IncludeAllInstances and
    IncludeUnsupportedInRegion are unread, and AllRegions is inert.

Verification

22 new tests in emulator/ec2_describe_filters_test.go; 20 of 21 fail at the base commit
(verified in a throwaway worktree, not asserted). The one that passes,
_InertNameSelectsEverything, pins an invariant by design. The three tripwire tables in
ec2_filter_names_test.go gained 12, 13 and 14 rows.

```
gofmt -l . && go build ./... && go vet ./... && golangci-lint run ./... # clean
make test # race on, green
make coverage # emulator 83.2%, total 82.5%
make docs-reference docs-reference-check docs-versions # up to date
npm --prefix docs run build # + href/id diff: no dangling anchors
go vet -C test/e2e ./... && go test -C test/e2e ./... # green
```

Twelve EC2 describes declared a Filters parameter on their reference page and
never parsed one: DescribeInstanceStatus, DescribeVpcs,
DescribeInternetGateways, DescribeKeyPairs, DescribeAvailabilityZones,
DescribePlacementGroups, DescribeAddresses, DescribeRegions,
DescribeInstanceTypes, DescribeSpotPriceHistory, DescribeLaunchTemplates and
DescribeLaunchTemplateVersions. A filter reached the handler and was discarded,
so a request for one resource answered with every resource.

Each gains an ec2FilterSpec. Three evaluate every name their page documents;
the rest evaluate what state can answer and accept the remainder as inert,
listed per operation in the docs. An undocumented name is refused. That split
closes TODO(#495) on DescribeInstanceTypes.

Wire changes: DescribeVpcs/CreateVpc rename vpcState to state, per AWS's own
samples; seven response members appear where a filter now selects on them; the
create and describe renderers for VPCs and internet gateways converge.
DescribeLaunchTemplateVersions filters before paginating. Three indexed list
parameters (LaunchTemplateId.N, LaunchTemplateName.N, ProductDescription.N)
were read at index 1 only.
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.91440% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/ec2_describe_filters.go 92.20% 18 Missing ⚠️
emulator/ec2_plugin.go 97.95% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 6f0f579 into main Aug 22, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the feat/695-filter-spec-per-describe branch August 22, 2026 02:15
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: fourteen describes never parse Filter.N, so a filter they are given is invisible

1 participant