HumanSignal/label-studio · error · ValidationError
list should not be empty
Error message
list should not be empty
What it means
DRF ValidationError from the validate_string_list field validator on ML ModelInterface, raised when the value is falsy (empty list, None, or empty string). The field must be a non-empty list of strings.
Source
Thrown at label_studio/ml_models/models.py:25
from django.db.models import Q
from django.utils.translation import gettext_lazy as _
from ml_model_providers.models import ModelProviderConnection, ModelProviders
from projects.models import Project
from rest_framework.exceptions import ValidationError
from tasks.models import Annotation, FailedPrediction, Prediction, PredictionMeta
logger = logging.getLogger(__name__)
# skills are partitions of projects (label config + input columns + output columns) into categories of labeling tasks
class SkillNames(models.TextChoices):
TEXT_CLASSIFICATION = 'TextClassification', _('TextClassification')
NAMED_ENTITY_RECOGNITION = 'NamedEntityRecognition', _('NamedEntityRecognition')
def validate_string_list(value):
if not value:
raise ValidationError('list should not be empty')
if not isinstance(value, list):
raise ValidationError('Value must be a list')
if not all(isinstance(item, str) for item in value):
raise ValidationError('All items in the list must be strings')
class ModelInterface(models.Model):
title = models.CharField(_('title'), max_length=500, null=False, blank=False, help_text='Model name')
description = models.TextField(_('description'), null=True, blank=True, help_text='Model description')
created_by = models.ForeignKey(
settings.AUTH_USER_MODEL, related_name='created_models', on_delete=models.SET_NULL, null=True
)
created_at = models.DateTimeField(_('created at'), auto_now_add=True)
updated_at = models.DateTimeField(_('updated at'), auto_now=True)View on GitHub (pinned to 0b49e9b539)
Solutions
- Provide a non-empty list value for the field
- Fix the ML backend to always return its full interface spec
- If empty should be legal, remove/replace the validator or make the field optional in the serializer
Example fix
// before
{"labels": []}
// after
{"labels": ["class_a", "class_b"]} Defensive patterns
Strategy: validation
Validate before calling
if not value:
raise ValueError('field must be a non-empty list before submitting the model interface') Type guard
def is_nonempty_str_list(v) -> bool:
return isinstance(v, list) and len(v) > 0 Try / catch
try:
interface.save()
except ValidationError as e:
if 'list should not be empty' in str(e):
interface.labels = fetch_default_labels_from_backend()
interface.save() Prevention
- Require ML backends to return non-empty interface specs
- Validate the model interface JSON before POSTing
- Treat empty-list responses from ML backend as backend failure
When it happens
Trigger: Saving or validating a ModelInterface whose list field (e.g. model controls/config lists) is [], None, or ''.
Common situations: ML backend returned an empty spec; client POSTed an omitted/empty field; deserialization defaulted to empty list instead of a required value.
Related errors
- Value must be a list
- All items in the list must be strings
- required
- FSMStateField is read-only. Use transitions to change state.
- {connection validation error}
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/71f4feb86a0a68a4.
Report an issue: GitHub.