fix(api): address code review feedback - logging, wildcard escaping, UX
- Add exception logging in saved search error handlers - Escape SQL LIKE wildcards (%, _) in tags filter to prevent unintended matching - Improve UI alert message for empty filter save attempt Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
+3
-1
@@ -143,7 +143,9 @@ def list_files_api(
|
||||
if tags:
|
||||
tag_list = [t.strip().lower() for t in tags.split(",") if t.strip()]
|
||||
for tag in tag_list:
|
||||
query = query.filter(FileRecord.ai_metadata.ilike(f"%{tag}%"))
|
||||
# Escape SQL LIKE wildcards to prevent unintended pattern matching
|
||||
escaped_tag = tag.replace("%", r"\%").replace("_", r"\_")
|
||||
query = query.filter(FileRecord.ai_metadata.ilike(f"%{escaped_tag}%"))
|
||||
|
||||
# Apply status filter (before pagination for correct counts)
|
||||
query = apply_status_filter(query, db, status)
|
||||
|
||||
Reference in New Issue
Block a user