HumanSignal/label-studio · error · ValidationError
_old_vs_new_data_keys_inconsistency_message(new_data_fields,
Error message
_old_vs_new_data_keys_inconsistency_message(new_data_fields, common_data_fields, file_upload.file.name)
What it means
During load_tasks_from_uploaded_files, when multiple files are imported/reimported, each file's task data keys must overlap with the keys of previously processed files. If a file's new_data_fields shares no key with common_data_fields, Label Studio raises a ValidationError built by _old_vs_new_data_keys_inconsistency_message naming the offending file.
Source
Thrown at label_studio/data_import/models.py:343
common_data_fields = set()
# scan all files
file_uploads = FileUpload.objects.filter(project=project)
if file_upload_ids:
file_uploads = file_uploads.filter(id__in=file_upload_ids)
for file_upload in file_uploads:
file_format = file_upload.format
if formats and file_format not in formats:
continue
new_tasks = file_upload.read_tasks(files_as_tasks_list)
for task in new_tasks:
task['file_upload_id'] = file_upload.id
new_data_fields = set(iter(new_tasks[0]['data'].keys())) if len(new_tasks) > 0 else set()
if not common_data_fields:
common_data_fields = new_data_fields
elif not common_data_fields.intersection(new_data_fields):
raise ValidationError(
_old_vs_new_data_keys_inconsistency_message(
new_data_fields, common_data_fields, file_upload.file.name
)
)
else:
common_data_fields &= new_data_fields
tasks += new_tasks
fileformats.append(file_format)
if trim_size is not None:
if len(tasks) > trim_size:
break
return tasks, dict(Counter(fileformats)), common_data_fields
@classmethod
def load_tasks_from_uploaded_files_streaming(View on GitHub (pinned to 0b49e9b539)
Solutions
- Rename keys in the offending file's tasks so they include at least one key common with the other files
- Import the mismatched file separately or into a project whose data keys match it
- Align the label config's $-keys across all files before reimport
Example fix
// before (file B)
[{"data": {"sentence": "hi"}}] // file A uses "text"
// after
[{"data": {"text": "hi"}}] Defensive patterns
Strategy: validation
Validate before calling
new_keys = set(new_tasks[0]['data'].keys()) if new_tasks else set()
if common_keys and not common_keys & new_keys:
raise ValueError(f"{file_name} data keys {new_keys} share nothing with {common_keys}") Type guard
def keys_intersect(task_batch, common):
if not task_batch:
return True
return bool(common & set(task_batch[0]['data'].keys())) Try / catch
try:
tasks = FileUpload.load_tasks_from_uploaded_files(project, upload_ids)
except ValidationError as e:
if 'data key' in str(e).lower() or 'inconsisten' in str(e).lower():
# identify offending file named in the message and fix its keys
...
raise Prevention
- Standardize data-key names across all files in a batch import
- Inspect existing project tasks' keys before reimport
- Normalize column headers before export
When it happens
Trigger: Calling load_tasks_from_uploaded_files (directly or via load_tasks, sync/async reimport, tasks_from_url) with several file uploads whose first tasks have disjoint data-key sets, e.g. file A uses {"image": ...} and file B uses {"text": ...}.
Common situations: Reimporting into an existing project after the label config/data keys changed; mixing exports from different projects; batch-uploading files prepared with different column names (image vs img, text vs sentence).
Related errors
- Task item should be dict
- Unsupported or invalid JSON structure
- Failed to parse JSON file {self.file_name}: {extract_message
- Your label config has more than one data key and direct file
- Failed to parse input file {self.file_name}: {extract_messag
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/f6e9d833a1108df9.
Report an issue: GitHub.