HumanSignal/label-studio · error · ValidationError
Your label config has more than one data key and direct file
Error message
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.
What it means
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.
Source
Thrown at label_studio/data_import/models.py:267
def format_could_be_tasks_list(self):
return self.format in ('.csv', '.tsv', '.txt')
def read_tasks(self, file_as_tasks_list=True):
file_format = self.format
try:
# file as tasks list
if file_format == '.csv' and file_as_tasks_list:
tasks = self.read_tasks_list_from_csv()
elif file_format == '.tsv' and file_as_tasks_list:
tasks = self.read_tasks_list_from_tsv()
elif file_format == '.txt' and file_as_tasks_list:
tasks = self.read_tasks_list_from_txt()
elif file_format == '.json':
tasks = self.read_tasks_list_from_json()
# otherwise - only one object tag should be presented in label config
elif not self.project.one_object_in_label_config:
raise ValidationError(
'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.'
)
# file as a single asset
elif file_format in ('.html', '.htm', '.xml'):
tasks = self.read_task_from_hypertext_body()
else:
tasks = self.read_task_from_uploaded_file()
except Exception as exc:
raise ValidationError('Failed to parse input file ' + self.file_name + ': ' + extract_message(exc))
return tasks
def read_tasks_streaming(self, file_as_tasks_list=True, batch_size=100):
"""Streaming version of read_tasks that yields tasks in batches for memory efficiency"""
file_format = self.format
View on GitHub (pinned to 0b49e9b539)
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
Example fix
// before (label config) <View><Image name="img" value="$image"/><Text name="txt" value="$text"/></View> // after (single data key) <View><Image name="img" value="$image"/></View>
Defensive patterns
Strategy: validation
Validate before calling
# before upload, check the config has one object tag
keys = project.get_obj_key_names() # or parse config XML for value="$..."
if len(keys) > 1 and file_format not in ('.json', '.csv'):
raise ValueError(f"Config has {len(keys)} data keys; use JSON/CSV import") Try / catch
try:
tasks = FileUpload.load_tasks_from_uploaded_files(project, upload_ids)
except ValidationError as e:
if 'more than one data key' in str(e):
# switch to JSON/CSV import or fix config
...
raise Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Validation failed on {}: {}
- Label config contains non-unique names:
- toName="{toName}" not found in names: {sorted(names)}
- Task item should be dict
- Unsupported or invalid JSON structure
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/eeb907afbd51456f.
Report an issue: GitHub.