Repository navigation
fix(ec2): wildcards in every filter value, and AWS's documented filter limits (#697) - #718
Merged
Merged
Conversation
…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 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.
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, soinstance-type=t3.*selected nothing at all — the silent-narrowing failure of an ignoredfilter, where a consumer sees a legitimate-looking empty set rather than an error.
DescribeInstanceTypeOfferingsandDescribeTagsalready matched throughec2FilterValueMatches, which is what made the split a defect: one documented value meant twodifferent things depending on which operation received it.
55 comparisons now route through the one matcher, across
DescribeInstances,DescribeVolumes,DescribeImages,DescribeSnapshots,DescribeSubnets,DescribeSecurityGroups,DescribeRouteTables,DescribeNatGatewaysandDescribeFleets.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 thenarrowing. #697's headline claim — that AWS's page self-contradicts on
?— is correct, andthe 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
ec2globMatchis 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.htmlpublishes no limits at all.All three are enforced in
ec2FilterSpec.check, so every operation with a filter specinherits 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
routeTableHasSubnetcomparedDescribeRouteTables'association.subnet-idexactly, and itsdoc comment classified it alongside
sgSourcesMatchas a record-to-record comparison. It isnot: 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 atall, where the same string in
SubnetId.Nis still a malformed ID.Behaviour changes
attachment.delete-on-terminationis case-sensitive. It was the tree's onlycase-insensitive value comparison, inherited from a hand-rolled loop that lowercased the
request value so
Trueselected a delete-on-termination attachment. AWS documents theopposite twice.
Truenow selects nothing; the lowercase form AWS's own examples use isunaffected.
InvalidParameterValue, HTTP 400,where it was previously accepted.
*or?. Nothingthat 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
*LimitExceededin the client-error table names a resource quota(
KeyPairLimitExceeded,NatGatewayLimitExceeded,TrafficMirrorFilterLimitExceeded, …) — soInvalidParameterValueis the only candidate, glossed as "A value specified in a parameter isnot 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 answerInvalid*.NotFound, so globbing themwould turn a NotFound contract into a match. Filter names are one of a fixed documented set.
sgSourcesMatchcompares 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_ValueSemanticsruns AWS's own prod/prods/production data setthrough a real
tag:Namefilter, plus a fourth subnet named the literalprod*so theescape rule is assertable. Eleven rows:
*at every position,?matching zero and one,prod\*, case sensitivity.TestEC2_FilterWildcards_EveryOperation— one case per previously-exact matcher, eachselecting 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.Nand the filter name.TestEC2_Filter_RequestLimits— both boundaries of all three limits, on two operations, toshow they come from the shared check rather than a handler.
Fail-before verified by mutation: reducing
ec2FilterValueMatchestopattern == valueandraising 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 overdist/services.html, andtest/e2e.Closes #697