Skip to content

fix(ec2): wildcards in every filter value, and AWS's documented filter limits (#697) - #718

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/697-wildcards-every-filter-value
Aug 21, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/697-wildcards-every-filter-value

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

AWS states EC2's filter-value wildcard rule once, for the whole family: "An asterisk (*)
matches zero or more characters, and a question mark (?) matches zero or one character." Nine
of substrate's eleven filter-value matchers compared with containsStr, so
instance-type=t3.* selected nothing at all — the silent-narrowing failure of an ignored
filter, where a consumer sees a legitimate-looking empty set rather than an error.
DescribeInstanceTypeOfferings and DescribeTags already matched through
ec2FilterValueMatches, which is what made the split a defect: one documented value meant two
different things depending on which operation received it.

55 comparisons now route through the one matcher, across DescribeInstances,
DescribeVolumes, DescribeImages, DescribeSnapshots, DescribeSubnets,
DescribeSecurityGroups, DescribeRouteTables, DescribeNatGateways and DescribeFleets.
Escaping (\*, \?, \\) and case sensitivity come with it.

Two corrections to the plan, both from AWS's own pages

? was not narrowed to exactly one character, because AWS's documentation refutes the
narrowing.
#697's headline claim — that AWS's page self-contradicts on ? — is correct, and
the resolution goes the other way from what the plan assumed. Zero-or-one is stated twice
normatively (Using_Filtering's "Filtering considerations" list, the one that governs the API,
and the console "Wildcard search" section) and worked through three times: "if you have a data
set with the values prod, prods, and production, a search of prod* matches all values,
whereas prod? matches only prod and prods". The "exactly 1 character" sentence appears once,
in the CLI examples, and is refuted by its own next sentence ("description is 'database' or
'database' followed by one character") and by database???? returning "up to four" characters.
Two normative statements and three worked examples against one self-refuting sentence, so
substrate's existing zero-or-one stands and ec2globMatch is untouched.

The filter limits are 50 / 200 / 255, not 200 / 200 / 256. Using_Filtering: "You can
specify up to 50 filters and up to 200 total filter values in a single request" and "Filter
strings can be up to 255 characters in length." API_Filter.html publishes no limits at all.
All three are enforced in ec2FilterSpec.check, so every operation with a filter spec
inherits them, and the count is checked before a name is validated — a 51st filter is refused
for being the 51st, not for whatever it is called.

A third correction, found during the sweep

routeTableHasSubnet compared DescribeRouteTables' association.subnet-id exactly, and its
doc comment classified it alongside sgSourcesMatch as a record-to-record comparison. It is
not: it matches a request filter value against a stored association, so it globs now.
association.subnet-id=subnet-* narrows to the route tables associated with any subnet at
all, where the same string in SubnetId.N is still a malformed ID.

Behaviour changes

  • attachment.delete-on-termination is case-sensitive. It was the tree's only
    case-insensitive value comparison, inherited from a hand-rolled loop that lowercased the
    request value so True selected a delete-on-termination attachment. AWS documents the
    opposite twice. True now selects nothing; the lowercase form AWS's own examples use is
    unaffected.
  • A filter value exceeding any of the three limits is now InvalidParameterValue, HTTP 400,
    where it was previously accepted.
  • Nine operations answer more than they used to for any value containing * or ?. Nothing
    that succeeds today starts failing.

Provenance

The limits are AWS's; the error code is substrate's reading. No EC2 error code exists for
a filter limit — every *LimitExceeded in the client-error table names a resource quota
(KeyPairLimitExceeded, NatGatewayLimitExceeded, TrafficMirrorFilterLimitExceeded, …) — so
InvalidParameterValue is the only candidate, glossed as "A value specified in a parameter is
not valid, is unsupported, or cannot be used."

Deliberately still exact

Identifier parameter lists (KeyName.N, GroupName.N, FleetId.N, RegionName.N,
InstanceType.N) assert their resources exist and answer Invalid*.NotFound, so globbing them
would turn a NotFound contract into a match. Filter names are one of a fixed documented set.
sgSourcesMatch compares two stored permissions, not a request value to a record.
containsStr's doc comment enumerates all six surviving call sites and why each stays exact.

Tests

New emulator/ec2_filter_wildcards_test.go:

  • TestEC2_FilterWildcards_ValueSemantics runs AWS's own prod/prods/production data set
    through a real tag:Name filter, plus a fourth subnet named the literal prod* so the
    escape rule is assertable. Eleven rows: * at every position, ? matching zero and one,
    prod\*, case sensitivity.
  • TestEC2_FilterWildcards_EveryOperation — one case per previously-exact matcher, each
    selecting with a pattern that is not a legal exact value, against a fixture that always
    holds a resource which must be excluded.
  • TestEC2_DescribeVolumes_DeleteOnTerminationIsCaseSensitive.
  • TestEC2_FilterWildcards_IdentifierParametersStayExact — KeyName.N, GroupName.N,
    FleetId.N, InstanceType.N and the filter name.
  • TestEC2_Filter_RequestLimits — both boundaries of all three limits, on two operations, to
    show they come from the shared check rather than a handler.

Fail-before verified by mutation: reducing ec2FilterValueMatches to pattern == value and
raising the three constants turns every wildcard, limit and case-sensitivity case red;
restoring them turns all green. Full gate green — gofmt, go build, go vet,
golangci-lint, make test (race), make coverage (82.3%), make docs-reference-check,
docs-versions, the VitePress build with an anchor-vs-id diff over dist/services.html, and
test/e2e.

Closes #697

…r limits (#697)

Route the nine previously-exact filter-value matchers through
ec2FilterValueMatches, so EC2's documented '*' and '?' work on every describe
rather than on the two whose reference pages state them. Enforce AWS's three
published request limits (50 filters, 200 total values, 255 characters) in
ec2FilterSpec.check, so every operation with a filter spec inherits them.

'?' is left matching zero or one character: AWS's page contradicts itself, and
two normative statements plus three worked examples outweigh the one
self-refuting sentence that says "exactly 1".

attachment.delete-on-termination becomes case-sensitive, and
DescribeRouteTables' association.subnet-id is reclassified as the filter value
it is rather than an identifier.

Closes #697
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.34177% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/ec2_plugin.go 60.86% 7 Missing and 2 partials ⚠️
emulator/ec2_fleet.go 66.66% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 2a88b7d into main Aug 21, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the feat/697-wildcards-every-filter-value branch August 21, 2026 23:50
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: filter values match exactly everywhere except DescribeInstanceTypeOfferings, where AWS documents wildcards for all of them

1 participant