{"record":{"id":"71f4feb86a0a68a4","repo":"HumanSignal/label-studio","slug":"list-should-not-be-empty","errorCode":null,"errorMessage":"list should not be empty","messagePattern":"list should not be empty","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/ml_models/models.py","lineNumber":25,"sourceCode":"from django.db.models import Q\nfrom django.utils.translation import gettext_lazy as _\nfrom ml_model_providers.models import ModelProviderConnection, ModelProviders\nfrom projects.models import Project\nfrom rest_framework.exceptions import ValidationError\nfrom tasks.models import Annotation, FailedPrediction, Prediction, PredictionMeta\n\nlogger = logging.getLogger(__name__)\n\n\n# skills are partitions of projects (label config + input columns + output columns) into categories of labeling tasks\nclass SkillNames(models.TextChoices):\n    TEXT_CLASSIFICATION = 'TextClassification', _('TextClassification')\n    NAMED_ENTITY_RECOGNITION = 'NamedEntityRecognition', _('NamedEntityRecognition')\n\n\ndef validate_string_list(value):\n    if not value:\n        raise ValidationError('list should not be empty')\n    if not isinstance(value, list):\n        raise ValidationError('Value must be a list')\n    if not all(isinstance(item, str) for item in value):\n        raise ValidationError('All items in the list must be strings')\n\n\nclass ModelInterface(models.Model):\n    title = models.CharField(_('title'), max_length=500, null=False, blank=False, help_text='Model name')\n\n    description = models.TextField(_('description'), null=True, blank=True, help_text='Model description')\n\n    created_by = models.ForeignKey(\n        settings.AUTH_USER_MODEL, related_name='created_models', on_delete=models.SET_NULL, null=True\n    )\n\n    created_at = models.DateTimeField(_('created at'), auto_now_add=True)\n\n    updated_at = models.DateTimeField(_('updated at'), auto_now=True)","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/ml_models/models.py#L7-L43","documentation":"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.","triggerScenarios":"Saving or validating a ModelInterface whose list field (e.g. model controls/config lists) is [], None, or ''.","commonSituations":"ML backend returned an empty spec; client POSTed an omitted/empty field; deserialization defaulted to empty list instead of a required value.","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"],"exampleFix":"// before\n{\"labels\": []}\n// after\n{\"labels\": [\"class_a\", \"class_b\"]}","handlingStrategy":"validation","validationCode":"if not value:\n    raise ValueError('field must be a non-empty list before submitting the model interface')","typeGuard":"def is_nonempty_str_list(v) -> bool:\n    return isinstance(v, list) and len(v) > 0","tryCatchPattern":"try:\n    interface.save()\nexcept ValidationError as e:\n    if 'list should not be empty' in str(e):\n        interface.labels = fetch_default_labels_from_backend()\n        interface.save()","preventionTips":["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"],"tags":["validation","ml","drf","serializer"],"backgroundTag":"list-should-not-be-empty","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}