HumanSignal/label-studio · error · ValidationError
{'predictions': prediction_errors}
Error message
{'predictions': prediction_errors} What it means
Raised in BaseTaskSerializerBulk.create when add_predictions returns validation errors for one or more imported predictions and the feature flag fflag_feat_utc_210_prediction_validation_15082025 is enabled for the org. The errors are wrapped as {'predictions': [...]}, failing the import transaction after tasks may have been staged, so prediction results (bad label values, wrong result types, malformed model output) must be fixed before the batch is accepted.
Source
Thrown at label_studio/tasks/serializers.py:724
task_drafts.append(drafts)
# extract reviews from snapshot annotations
for annotation in annotations:
reviews = annotation.get('reviews', [])
self._insert_valid_user_reviews(reviews, members_email_to_id, default_user)
task_reviews.append(reviews)
db_tasks = self.add_tasks(task_annotations, task_predictions, validated_tasks)
db_annotations = self.add_annotations(task_annotations, user)
prediction_errors = self.add_predictions(task_predictions)
raise_prediction_errors = True
if not flag_set('fflag_feat_utc_210_prediction_validation_15082025', user=ff_user):
raise_prediction_errors = False
# If there are prediction validation errors, raise them
if prediction_errors and raise_prediction_errors:
raise ValidationError({'predictions': prediction_errors})
if db_annotations:
# Keep ProjectSummary counters in sync for imported annotations so
# label-distribution statistics don't require a manual summary reset.
self.project.summary.update_created_annotations_and_labels(db_annotations)
self.post_process_annotations(user, db_annotations, 'imported')
self.post_process_tasks(self.project.id, [t.id for t in self.db_tasks])
self.post_process_custom_callback(self.project.id, user)
if flag_set('fflag_feat_back_lsdv_5307_import_reviews_drafts_29062023_short', user=ff_user):
with transaction.atomic():
# build mapping between new and old ids in annotations,
# we need it because annotation ids will be known only after saving to db
annotation_mapping = {v.import_id: v.id for v in db_annotations}
annotation_mapping[None] = None
# the sequence of add_ functions is very important because of references to ids
db_drafts = self.add_drafts(task_drafts, db_tasks, annotation_mapping, self.project)View on GitHub (pinned to 0b49e9b539)
Solutions
- Inspect the 'predictions' detail in the error to find the failing prediction results and fix the label values / result structure
- Regenerate predictions with model output that exactly matches the project's current labeling config (label names, from_name/to_name, result type)
- Update the project labeling config to include the labels used by the predictions before importing
- Strip the 'predictions' key from the import payload if predictions are not needed
- Disable the fflag_feat_utc_210_prediction_validation_15082025 flag for the org to restore the old lenient behavior (predictions errors logged, not raised)
Example fix
// before
{"predictions": [{"result": [{"from_name": "sentiment", "type": "choices", "value": {"choices": ["positive"]}}]}]}
// after — 'mood' config label actually defined in the project
{"predictions": [{"result": [{"from_name": "mood", "to_name": "text", "type": "choices", "value": {"choices": ["positive"]}}]}]} Defensive patterns
Strategy: try-catch
Validate before calling
def check_predictions(tasks, config_labels, config_from_names):
for t in tasks:
for p in t.get('predictions', []):
for r in p.get('result', []):
if r.get('from_name') not in config_from_names:
raise ValueError(f"Unknown from_name {r.get('from_name')!r}")
for lbl in r.get('value', {}).get('choices', []):
if lbl not in config_labels:
raise ValueError(f'Unknown label {lbl!r} not in labeling config') Try / catch
from rest_framework.exceptions import ValidationError
try:
client.import_tasks(project_id, tasks)
except ValidationError as e:
if isinstance(e.detail, dict) and 'predictions' in e.detail:
bad = e.detail['predictions']
# drop or fix invalid predictions, then retry the import
for i, err in enumerate(bad):
print('Prediction error:', i, err)
else:
raise Prevention
- Generate predictions with label names matching the project's current labeling config
- Fetch the labeling config and diff its labels against prediction values before import
- Validate a sample prediction batch against PredictionSerializer before bulk import
- Keep model output schema (from_name/to_name/type/value) aligned with the config's control tags
When it happens
Trigger: Importing tasks whose 'predictions' arrays contain results that fail PredictionSerializer validation — e.g. label values not present in the project's labeling config, result entries missing 'from_name'/'to_name'/'type', or invalid score/value shapes — while the UTC-210 prediction-validation flag is on.
Common situations: Model-generated pre-annotations using label names that don't match the current label config; exports from projects with a different labeling config; predictions copied from a config that was later renamed/edited.
Related errors
- Prediction validation failed ({len(validation_errors)} error
- "url" must be 2048 characters or fewer
- {item} contains invalid "task" field: task ID {task_id} not
- batch_validation_errors
- validation_errors
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/5b004a460fbd1d7f.
Report an issue: GitHub.