Skip to content
Open
6 changes: 3 additions & 3 deletions flower/utils/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
import time
import json
import ast

from .search import parse_search_terms, satisfies_search_terms

Expand Down Expand Up @@ -80,14 +81,14 @@ def parse_args(args):
# Attempt to parse JSON
parsed_args = json.loads(args)
if isinstance(parsed_args, str) and parsed_args.startswith('(') and parsed_args.endswith(')'):
return eval(parsed_args) # Handle stringified tuples
return ast.literal_eval(parsed_args) # Handle stringified tuples safely
return parsed_args
except (json.JSONDecodeError, SyntaxError):
# Fallback for stringified tuples or ellipsis
if args == '...':
return [...]
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning a list containing an Ellipsis object is problematic. The Ellipsis object (...) is typically used as a placeholder but returning it wrapped in a list can cause issues downstream. Consider returning an empty list or raising a ValueError to indicate that '...' is not a valid argument format.

Suggested change
return [...]
return []

Copilot uses AI. Check for mistakes.
if args.startswith('(') and args.endswith(')'):
return eval(args)
return ast.literal_eval(args)
return [args]

def parse_kwargs(kwargs):
Expand All @@ -102,7 +103,6 @@ def parse_kwargs(kwargs):
except json.JSONDecodeError:
try:
# Fallback for stringified dictionaries
import ast
if kwargs.startswith('{') and kwargs.endswith('}'):
return ast.literal_eval(kwargs)
except (ValueError, SyntaxError):
Expand Down