Fix ec2 filter by empty tag value (#3605)
* Fix ec2 filter by empty tag value Return `None` instead of an empty string when the tag key does not exist and replace the falsy check with a more explicit `is None`, which allows empty string values to correctly pass through the filter comparator. Behavior confirmed against a real AWS backend. Closes #3603 * Make test case more explicit Test case now pulled directly from the issue report (#3603). Co-authored-by: Bert Blommers <bblommers@users.noreply.github.com>
This commit is contained in:
parent
8f4c3e4a51
commit
38124ab1c9
3 changed files with 43 additions and 2 deletions
|
|
@ -249,7 +249,7 @@ class TaggedEC2Resource(BaseModel):
|
|||
if tag["key"] == tagname:
|
||||
return tag["value"]
|
||||
|
||||
return ""
|
||||
return None
|
||||
elif filter_name == "tag-key":
|
||||
return [tag["key"] for tag in tags]
|
||||
elif filter_name == "tag-value":
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ def filter_internet_gateways(igws, filter_dict):
|
|||
def is_filter_matching(obj, filter, filter_value):
|
||||
value = obj.get_filter_value(filter)
|
||||
|
||||
if not filter_value:
|
||||
if filter_value is None:
|
||||
return False
|
||||
|
||||
if isinstance(value, six.string_types):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue