HumanSignal/label-studio · error · ValidationError
range(start:int) requires one start argument.
Error message
range(start:int) requires one start argument.
What it means
For the 'range' command, add_expression enforces exactly one argument: range(start:int). Supplying zero or multiple arguments raises ValidationError {'value': 'range(start:int) requires one start argument.'}.
Source
Thrown at label_studio/data_manager/actions/data_columns.py:289
def add_expression(queryset, size, value, value_name):
if '(' not in value or not value.endswith(')'):
raise ValidationError({'value': 'Expression must use the form command(arguments).'})
command, args = value.split('(', 1)
if not command:
raise ValidationError({'value': 'Expression command is required.'})
args = process_arrays(args)
args = args.replace(')', '').split(',')
args = [] if len(args) == 1 and args[0] == '' else args
for i, arg in enumerate(args):
args[i] = arg.replace(';', ',').replace("'", '"')
sample_values = None
if command == 'range':
if len(args) != 1:
raise ValidationError({'value': 'range(start:int) requires one start argument.'})
start = int(args[0])
elif command == 'sample':
if args:
raise ValidationError({'value': 'sample() does not accept arguments.'})
sample_values = iter(random.sample(range(0, size), size))
elif command == 'random':
if len(args) != 2:
raise ValidationError({'value': 'random(min, max) requires two arguments.'})
minimum, maximum = int(args[0]), int(args[1])
elif command == 'choices':
if not 0 < len(args) < 3:
raise ValidationError({'value': 'choices(values:list, weights:list) requires one or two arguments.'})
weights = json.loads(args[1]) if len(args) == 2 else None
choices = json.loads(args[0])
View on GitHub (pinned to 0b49e9b539)
Solutions
- Pass exactly one integer argument: 'range(N)' generates a sequence based on task index starting at N.
- Remove extra arguments or switch to a different command if a start/stop range is needed.
- Cast arguments to int in the payload (they are parsed with int(args[0])).
Example fix
// before value = 'range(1, 10)' // after value = 'range(1)'
Defensive patterns
Strategy: validation
Validate before calling
args_part = value[value.index('(')+1:-1].strip()
if value.startswith('range'):
assert len([a for a in args_part.split(',') if a.strip()]) == 1, 'range takes exactly one int argument' Type guard
import re
def is_valid_range_expression(value):
return isinstance(value, str) and re.fullmatch(r'range\(\s*-?\d+\s*\)', value) is not None Try / catch
from rest_framework.exceptions import ValidationError
try:
add_data_field(project, qs, request=request)
except ValidationError as e:
if 'requires one start argument' in str(e):
fix_to_single_arg_expression() Prevention
- Remember range() here is not Python's range(start, stop) — only one int argument.
- Strip whitespace and split arguments the same way the server does before validating.
- Show a single numeric input in the UI for the range command.
When it happens
Trigger: Submitting Expression 'range()' (no args), 'range(1, 10)' or 'range(1;10)' (two args — note ';' is converted to ',' before this check), or 'range( 5 , 6 )'.
Common situations: User assumes Python-like range(start, stop) semantics and passes two arguments; empty parentheses from the dialog template.
Related errors
- Expression must use the form command(arguments).
- Expression command is required.
- Choose a supported column type.
- Select an existing column or enter a new column name.
- Column name cannot contain {UNQUERYABLE_COLUMN_NAME_CHARACTE
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/ca6dbceda1015705.
Report an issue: GitHub.