{"record":{"id":"f6e9d833a1108df9","repo":"HumanSignal/label-studio","slug":"old-vs-new-data-keys-inconsistency-message-new-da","errorCode":null,"errorMessage":"_old_vs_new_data_keys_inconsistency_message(new_data_fields, common_data_fields, file_upload.file.name)","messagePattern":"_old_vs_new_data_keys_inconsistency_message\\(new_data_fields, common_data_fields, file_upload\\.file\\.name\\)","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/data_import/models.py","lineNumber":343,"sourceCode":"        common_data_fields = set()\n\n        # scan all files\n        file_uploads = FileUpload.objects.filter(project=project)\n        if file_upload_ids:\n            file_uploads = file_uploads.filter(id__in=file_upload_ids)\n        for file_upload in file_uploads:\n            file_format = file_upload.format\n            if formats and file_format not in formats:\n                continue\n            new_tasks = file_upload.read_tasks(files_as_tasks_list)\n            for task in new_tasks:\n                task['file_upload_id'] = file_upload.id\n\n            new_data_fields = set(iter(new_tasks[0]['data'].keys())) if len(new_tasks) > 0 else set()\n            if not common_data_fields:\n                common_data_fields = new_data_fields\n            elif not common_data_fields.intersection(new_data_fields):\n                raise ValidationError(\n                    _old_vs_new_data_keys_inconsistency_message(\n                        new_data_fields, common_data_fields, file_upload.file.name\n                    )\n                )\n            else:\n                common_data_fields &= new_data_fields\n\n            tasks += new_tasks\n            fileformats.append(file_format)\n\n            if trim_size is not None:\n                if len(tasks) > trim_size:\n                    break\n\n        return tasks, dict(Counter(fileformats)), common_data_fields\n\n    @classmethod\n    def load_tasks_from_uploaded_files_streaming(","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/data_import/models.py#L325-L361","documentation":"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.","triggerScenarios":"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\": ...}.","commonSituations":"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).","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"],"exampleFix":"// before (file B)\n[{\"data\": {\"sentence\": \"hi\"}}]  // file A uses \"text\"\n// after\n[{\"data\": {\"text\": \"hi\"}}]","handlingStrategy":"validation","validationCode":"new_keys = set(new_tasks[0]['data'].keys()) if new_tasks else set()\nif common_keys and not common_keys & new_keys:\n    raise ValueError(f\"{file_name} data keys {new_keys} share nothing with {common_keys}\")","typeGuard":"def keys_intersect(task_batch, common):\n    if not task_batch:\n        return True\n    return bool(common & set(task_batch[0]['data'].keys()))","tryCatchPattern":"try:\n    tasks = FileUpload.load_tasks_from_uploaded_files(project, upload_ids)\nexcept ValidationError as e:\n    if 'data key' in str(e).lower() or 'inconsisten' in str(e).lower():\n        # identify offending file named in the message and fix its keys\n        ...\n    raise","preventionTips":["Standardize data-key names across all files in a batch import","Inspect existing project tasks' keys before reimport","Normalize column headers before export"],"tags":["data-import","schema-mismatch","reimport"],"backgroundTag":"data-key-mismatch","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}