HumanSignal/label-studio · error · ValidationError
preannotated_fields
Error message
preannotated_fields
What it means
reformat_predictions converts legacy 'preannotated_fields' style data into task+predictions structures. While processing it collects validation errors about missing pre-annotation fields, and if any were found and raise_errors is set, it raises ValidationError({'preannotated_fields': validation_errors}). The dict key 'preannotated_fields' in the response identifies this error family.
Source
Thrown at label_studio/data_import/functions.py:281
'from_name': field,
'to_name': to_name,
'type': prediction_type,
'value': prediction_value,
}
],
'score': 1.0,
'model_version': 'preannotated',
}
predictions.append(prediction)
# Create new task structure
new_task = {'data': task_data, 'predictions': predictions}
new_tasks.append(new_task)
# If there are validation errors, raise them
if validation_errors and raise_errors:
raise ValidationError({'preannotated_fields': validation_errors})
return new_tasks
post_process_reimport = load_func(settings.POST_PROCESS_REIMPORT)
def _async_reimport_background_streaming(reimport, project, organization_id, user):
"""Streaming version of reimport that processes tasks in batches to reduce memory usage"""
try:
# Get batch size from settings or use default
batch_size = settings.REIMPORT_BATCH_SIZE
# Initialize counters
total_task_count = 0
total_annotation_count = 0
total_prediction_count = 0
all_found_formats = {}View on GitHub (pinned to 0b49e9b539)
Solutions
- Read validation_errors under the 'preannotated_fields' key; each entry names the missing/invalid field
- Add the expected pre-annotated field keys to each task's data object
- Update the import payload to the current annotations/predictions format instead of legacy preannotated_fields
- Check the project/template configuration for which data keys it expects
- Verify upstream data generation emits the required keys for every task
Example fix
// before: task data missing the pre-annotated field
{"data": {"text": "hello"}}
// after: include expected preannotated field
{"data": {"text": "hello", "preannotated_choices": ["positive"]}} Defensive patterns
Strategy: validation
Validate before calling
required = {'preannotated_choices'} # keys the template/project expects
for t in tasks:
missing = required - t.get('data', {}).keys()
if missing:
raise ValueError(f'task data missing preannotated fields: {missing}') Type guard
def has_preannotated_fields(task: dict, required: set) -> bool:
data = task.get('data') if isinstance(task, dict) else None
return isinstance(data, dict) and required.issubset(data.keys()) Try / catch
try:
requests.post(import_url, headers=H, json=tasks).raise_for_status()
except requests.HTTPError as e:
detail = e.response.json()
if 'preannotated_fields' in detail:
log.error('Pre-annotation field errors: %s', detail['preannotated_fields']) Prevention
- Match task data keys to the template's expected pre-annotated fields before import
- Migrate legacy preannotated_fields payloads to the current predictions format
- Schema-check generated task dicts (data key presence) in your pipeline
When it happens
Trigger: Importing tasks whose data references pre-annotation fields (e.g. data keys configured as pre-annotated sources) that are missing or invalid in the item, during sync_import, async import background processing, or streaming re-import — with raise_errors enabled.
Common situations: Legacy pre-annotation workflows where the expected data keys were renamed or omitted; re-importing old exports into projects with different data key configuration; templates expecting {data}['annotations']-style fields that the payload lacks; automated pipelines producing tasks without the pre-annotated field keys.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- Prediction validation failed ({len(validation_errors)} error
- "url" must be 2048 characters or fewer
- Can't deserialize tasks due to {errors}
- "url" is not found in request data
- load_tasks: No data found in DATA or in FILES
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/c3542155a1fc1dc1.
Report an issue: GitHub.