{"record":{"id":"eeb907afbd51456f","repo":"HumanSignal/label-studio","slug":"your-label-config-has-more-than-one-data-key-and-d","errorCode":null,"errorMessage":"Your label config has more than one data key and direct file upload supports only one data key. To import data with multiple data keys, use a JSON or CSV file.","messagePattern":"Your label config has more than one data key and direct file upload supports only one data key\\. To import data with multiple data keys, use a JSON or CSV file\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/data_import/models.py","lineNumber":267,"sourceCode":"    def format_could_be_tasks_list(self):\n        return self.format in ('.csv', '.tsv', '.txt')\n\n    def read_tasks(self, file_as_tasks_list=True):\n        file_format = self.format\n        try:\n            # file as tasks list\n            if file_format == '.csv' and file_as_tasks_list:\n                tasks = self.read_tasks_list_from_csv()\n            elif file_format == '.tsv' and file_as_tasks_list:\n                tasks = self.read_tasks_list_from_tsv()\n            elif file_format == '.txt' and file_as_tasks_list:\n                tasks = self.read_tasks_list_from_txt()\n            elif file_format == '.json':\n                tasks = self.read_tasks_list_from_json()\n\n            # otherwise - only one object tag should be presented in label config\n            elif not self.project.one_object_in_label_config:\n                raise ValidationError(\n                    'Your label config has more than one data key and direct file upload supports only '\n                    'one data key. To import data with multiple data keys, use a JSON or CSV file.'\n                )\n\n            # file as a single asset\n            elif file_format in ('.html', '.htm', '.xml'):\n                tasks = self.read_task_from_hypertext_body()\n            else:\n                tasks = self.read_task_from_uploaded_file()\n\n        except Exception as exc:\n            raise ValidationError('Failed to parse input file ' + self.file_name + ': ' + extract_message(exc))\n        return tasks\n\n    def read_tasks_streaming(self, file_as_tasks_list=True, batch_size=100):\n        \"\"\"Streaming version of read_tasks that yields tasks in batches for memory efficiency\"\"\"\n        file_format = self.format\n","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/data_import/models.py#L249-L285","documentation":"When a file is uploaded directly and its format is not JSON/CSV (which can map columns to multiple data keys), read_tasks requires the label config to have exactly one object tag (one data key). If project.one_object_in_label_config is false, this ValidationError is raised because the single uploaded file cannot populate multiple data keys.","triggerScenarios":"Calling load_tasks_from_uploaded_files with a .txt/.tsv/other-format file (not .json/.csv) while the project's label config contains more than one <Image>/<Text>-style object tag (one_object_in_label_config is False).","commonSituations":"Label config with both an image and a text key while uploading a plain txt or binary file; multi-view configs (e.g. image + audio) combined with direct file upload; users switching configs after setting up an import.","solutions":["Simplify the label config to a single object tag matching the uploaded file","Import via a JSON or CSV file that supplies values for all data keys in the config","Add a parameter alias / default value for the extra data key in the config"],"exampleFix":"// before (label config)\n<View><Image name=\"img\" value=\"$image\"/><Text name=\"txt\" value=\"$text\"/></View>\n// after (single data key)\n<View><Image name=\"img\" value=\"$image\"/></View>","handlingStrategy":"validation","validationCode":"# before upload, check the config has one object tag\nkeys = project.get_obj_key_names()  # or parse config XML for value=\"$...\"\nif len(keys) > 1 and file_format not in ('.json', '.csv'):\n    raise ValueError(f\"Config has {len(keys)} data keys; use JSON/CSV import\")","typeGuard":null,"tryCatchPattern":"try:\n    tasks = FileUpload.load_tasks_from_uploaded_files(project, upload_ids)\nexcept ValidationError as e:\n    if 'more than one data key' in str(e):\n        # switch to JSON/CSV import or fix config\n        ...\n    raise","preventionTips":["Keep direct file uploads paired with single-object label configs","Use JSON/CSV whenever the config has 2+ data keys","Check one_object_in_label_config before importing raw files"],"tags":["label-config","data-import","validation"],"backgroundTag":"label-config-multiple-data-keys","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}