Repository navigation
fix(ec2): a valueless tag: filter on DescribeImages matches nothing (#686) - #694
Merged
Merged
Conversation
…686) describeImages parsed Filter.N itself rather than through extractEC2Filters, and the two disagreed three ways: a tag: filter with no values matched any value (which is tag-key's job, and tag-key was unsupported); the walk broke out of its value loop on the first empty string, so an explicitly empty value arrived as no values at all; and adopting the shared extractor would have collapsed a repeated filter name to whichever came last. Adopt extractEC2Filters, fix its map collapse by appending so repeated names OR their values, and add tag-key so the any-value question keeps a spelling.
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.
describeImagesparsedFilter.Nitself instead of callingextractEC2Filters, and thetwo parsers disagreed in three ways that compounded into one wrong answer.
The defect #686 reports. A
tag:<key>filter with no value matched any value:That is
tag-key's question, andtag-keywas unsupported — so this operation had thewrong spelling of the any-value question and not the right one.
DescribeInstances(
default: return false) andDescribeVolumesboth match nothing for the valueless form.AWS settles neither reading:
Using_Filteringsays only "You can't specify a filter valueof null". Matching nothing is substrate's reading, and it is now substrate's answer at all
three sites rather than two of three.
What the hand-rolled walk added.
if fv == "" { break }truncated the value list, soFilter.1.Value.1=arrived as no values and inherited the rule above. An empty filtervalue is a value — it asks for a tag whose value is the empty string — and every other
caller of
extractEC2Filtersdistinguishes the two. Adopting the shared extractor fixesthis and the first defect together, and leaves one filter parser in the plugin instead of
two that disagreed.
What adopting it would have broken, so it is fixed here too.
extractEC2Filterskeyeda map by name and overwrote, so a repeated filter name kept only the last. The old walk
appended each
Filter.Nto a slice and ANDed them, which is right for distinct names —and
extractEC2Filtersgets those right too, since they are separate map keys. Thecollision is the same name twice, where overwriting silently discarded the first entry
with no indication. AWS documents filters ANDed and values within a filter ORed, and says
nothing about a repeated name; merging the value lists answers it as an OR, which is
substrate's reading. Overwriting was not a reading of anything. This affects every EC2
describe that parses filters, which is why it is pinned by its own test.
tag-keyarrives in the same PR because the first fix takes away the spelling callers wereusing for it. Without it the change would be a pure removal.
Fail-before
The issue's acceptance criterion asks that the test pinning the old rule be updated. No
such test existed — only three tests in the repo pin any unknown/empty filter behaviour and
none covers
DescribeImages— soemulator/ec2_image_filters_test.gois written here asthe fail-before. Recorded against unfixed code:
ValuelessTagFilterMatchesNothingtag:Envwith no value returned theEnv=prodAMIExplicitEmptyTagValuetag:Env=returned theEnv=prodAMITagKeyFilterDistinctFilterNamesAreANDedRepeatedFilterNameORsItsValuesappendtofilters[name] = vals, which returned onlystagingVerification
gofmt -lclean,go build ./...,go vet ./...,golangci-lint run ./...(0 issues),go test -race -count=1 ./emulator/(full package, no-runfilter),go test -C test/e2e ./...,make docs-reference-check,scripts/check-doc-versions.sh,npm --prefix docs run build— all pass.Nothing else needed changing: no test asserts a
DescribeImagesresponse byte-exactly, andno golden-XML fixture exists in the repo.
Compatibility
Three behaviour changes, all named in
CHANGELOG.mdanddocs/services.md: the valuelesstag:form now matches nothing (usetag-key), an explicitly empty filter value is nowhonoured as the empty string, and a repeated filter name now ORs rather than dropping the
earlier entry — the last on every EC2 describe, not only this one.
Closes #686