backend/utils/str_utils.py:27-39:
def convert_string_to_list(items_str: Optional[str]) -> List[int]:
"""Convert comma-separated string to list of integers for processing"""
if not items_str or items_str.strip() == "":
return []
return [int(item.strip()) for item in items_str.split(",") if item.strip().isdigit()]
Two related bugs in one line:
str.isdigit() returns False for "-1", "+1", and " 3 " (after strip() only stripped outer whitespace — fine — but for any digit-with-sign it's False). The companion convert_list_to_string (line 12) happily emits a negative integer; round-tripping a list containing -1 therefore drops it silently.
- Non-digit garbage like
"a,1,b,2" is silently filtered to [1, 2]. There's no warning, no exception, and no log line — the caller has no way to distinguish "no values supplied" from "your input was malformed".
Repro
>>> convert_string_to_list(convert_list_to_string([1, -2, 3]))
[1, 3]
>>> convert_string_to_list("a, 1, b, 2")
[1, 2] # silently dropped 'a' and 'b'
Suggested fix
def convert_string_to_list(items_str: Optional[str]) -> List[int]:
if not items_str or not items_str.strip():
return []
out = []
for raw in items_str.split(","):
item = raw.strip()
if not item:
continue
try:
out.append(int(item))
except ValueError:
logger.warning("convert_string_to_list: dropping non-integer entry %r", item)
return out
That preserves negatives, surfaces malformed input via logs, and keeps the same return shape.
Category: A (logic/correctness). Severity: Low–Medium depending on where the round-trip is used in the DB layer.
backend/utils/str_utils.py:27-39:Two related bugs in one line:
str.isdigit()returnsFalsefor"-1","+1", and" 3 "(afterstrip()only stripped outer whitespace — fine — but for any digit-with-sign it'sFalse). The companionconvert_list_to_string(line 12) happily emits a negative integer; round-tripping a list containing-1therefore drops it silently."a,1,b,2"is silently filtered to[1, 2]. There's no warning, no exception, and no log line — the caller has no way to distinguish "no values supplied" from "your input was malformed".Repro
Suggested fix
That preserves negatives, surfaces malformed input via logs, and keeps the same return shape.
Category: A (logic/correctness). Severity: Low–Medium depending on where the round-trip is used in the DB layer.