Skip to content

Commit

Permalink
fix OS set name logic
Browse files Browse the repository at this point in the history
  • Loading branch information
FabriciaDinizRH committed Jan 15, 2025
1 parent 779a8bc commit 1a7d0ba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/filtering/db_custom_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, name="", comparator="", version=None):
os_names = get_valid_os_names()

try:
if name and name.lower() not in [name.lower() for name in os_names]:
if not name or name.lower() not in [name.lower() for name in os_names]:
raise ValidationException(f"operating_system filter only supports these OS names: {os_names}.")

if version is None:
Expand Down Expand Up @@ -140,7 +140,7 @@ def separate_operating_system_filters(filter_url_params) -> list[OsFilter]:
# filter_url_params is a dict
for filter_key in filter_url_params.keys():
if filter_key == "name":
((os_comparator, os_name),) = filter_url_params["name"].items()
((os_comparator, os_name),) = filter_url_params[filter_key].items()
version_node = {os_comparator: [None]}
else:
os_name = filter_key
Expand Down Expand Up @@ -174,7 +174,7 @@ def build_operating_system_filter(filter_param: dict) -> tuple:
# Uses the comparator with None, resulting in either is_(None) or is_not(None)
os_filter_list.append(os_field.astext.operate(comparator, None))

elif os_filter.comparator in ["eq", "neq"]:
elif os_filter.comparator in ["eq", "neq", "ne"]:
os_filters = [
func.lower(os_field["name"].astext).operate(comparator, os_filter.name.lower()),
]
Expand Down

0 comments on commit 1a7d0ba

Please sign in to comment.