Skip to content

Commit c961689

Browse files
committed
Filter config error handling on empty entries
1 parent 7edf574 commit c961689

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

healthcheck.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,30 @@ def should_include_device(device):
143143
]
144144

145145
# OS filtering
146-
if INCLUDE_OS and INCLUDE_OS != "":
147-
os_patterns = [p.strip() for p in INCLUDE_OS.split(",")]
146+
if INCLUDE_OS and INCLUDE_OS.strip() != "":
147+
os_patterns = [p.strip() for p in INCLUDE_OS.split(",") if p.strip()]
148+
if not os_patterns: # Skip if no valid patterns after cleaning
149+
return True
148150
if not any(fnmatch.fnmatch(device["os"], pattern) for pattern in os_patterns):
149151
return False
150-
elif EXCLUDE_OS and EXCLUDE_OS != "":
151-
os_patterns = [p.strip() for p in EXCLUDE_OS.split(",")]
152+
elif EXCLUDE_OS and EXCLUDE_OS.strip() != "":
153+
os_patterns = [p.strip() for p in EXCLUDE_OS.split(",") if p.strip()]
154+
if not os_patterns: # Skip if no valid patterns after cleaning
155+
return True
152156
if any(fnmatch.fnmatch(device["os"], pattern) for pattern in os_patterns):
153157
return False
154158

155159
# Identifier filtering
156-
if INCLUDE_IDENTIFIER and INCLUDE_IDENTIFIER != "":
157-
identifier_patterns = [p.strip().lower() for p in INCLUDE_IDENTIFIER.split(",")]
160+
if INCLUDE_IDENTIFIER and INCLUDE_IDENTIFIER.strip() != "":
161+
identifier_patterns = [p.strip().lower() for p in INCLUDE_IDENTIFIER.split(",") if p.strip()]
162+
if not identifier_patterns: # Skip if no valid patterns after cleaning
163+
return True
158164
if not any(any(fnmatch.fnmatch(identifier, pattern) for pattern in identifier_patterns) for identifier in identifiers):
159165
return False
160-
elif EXCLUDE_IDENTIFIER and EXCLUDE_IDENTIFIER != "":
161-
identifier_patterns = [p.strip().lower() for p in EXCLUDE_IDENTIFIER.split(",")]
166+
elif EXCLUDE_IDENTIFIER and EXCLUDE_IDENTIFIER.strip() != "":
167+
identifier_patterns = [p.strip().lower() for p in EXCLUDE_IDENTIFIER.split(",") if p.strip()]
168+
if not identifier_patterns: # Skip if no valid patterns after cleaning
169+
return True
162170
if any(any(fnmatch.fnmatch(identifier, pattern) for pattern in identifier_patterns) for identifier in identifiers):
163171
return False
164172

0 commit comments

Comments
 (0)