{"record":{"id":"e7b483db962359b2","repo":"HumanSignal/label-studio","slug":"task-is-required-to-resolve-uris-in-data-data","errorCode":null,"errorMessage":"Task is required to resolve URIs in data={data}","messagePattern":"Task is required to resolve URIs in data=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"label_studio/io_storages/base_models.py","lineNumber":460,"sourceCode":"        if isinstance(data, list):\n            resolved = [self.resolve_uris(item, task) or item for item in data]\n            return resolved\n\n        if isinstance(data, dict):\n            resolved = {key: self.resolve_uris(val, task) or val for key, val in data.items()}\n            return resolved\n\n        if not isinstance(data, str) or self.url_scheme not in data:\n            return None\n\n        try:\n            all_uris = get_all_uris_via_regex(data, prefixes=[self.url_scheme])\n            if not all_uris:\n                return None\n\n            if task is None:\n                logger.error(f'Task is required to resolve URIs in data={data}', exc_info=True)\n                raise ValueError(f'Task is required to resolve URIs in data={data}')\n\n            resolved = data\n            any_resolved = False\n            for extracted_uri, _ in all_uris:\n                if not self.can_resolve_url(extracted_uri):\n                    continue\n                proxy_url = urljoin(\n                    settings.HOSTNAME,\n                    reverse('storages:task-storage-data-resolve', kwargs={'task_id': task.id})\n                    + f'?fileuri={base64.urlsafe_b64encode(extracted_uri.encode()).decode()}',\n                )\n                resolved = resolved.replace(extracted_uri, proxy_url, 1)\n                any_resolved = True\n            return resolved if any_resolved else None\n        except Exception:\n            logger.info(f\"Can't resolve URIs in data={data}\", exc_info=True)\n            return None\n","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/io_storages/base_models.py#L442-L478","documentation":"resolve_uris replaces all storage-scheme URIs found in a task data string with proxy URLs; that substitution requires the owning Task. It raises this ValueError when at least one resolvable URI was found (get_all_uris_via_regex matched) but the task argument is None, since each URI needs task.id for the proxy route.","triggerScenarios":"Calling resolve_uris(data, task=None) where data contains at least one URI matching the storage url_scheme prefix and passing can_resolve_url.","commonSituations":"Bulk URI resolution utilities invoked without task context; export/import flows that pass data strings around without carrying the Task reference.","solutions":["Provide the Task instance owning the data when calling resolve_uris.","Skip resolution when no task is available — check can_resolve_url / regex yourself first and only call with a task.","Fetch or pass the task id through your pipeline so resolution happens in task context."],"exampleFix":"// before\nresolved = storage.resolve_uris(task_data_json, task=None)\n\n// after\nresolved = storage.resolve_uris(task_data_json, task=task)  # task from the annotation/loop context","handlingStrategy":"validation","validationCode":"from label_studio.io_storages.functions import get_all_uris_via_regex\nall_uris = get_all_uris_via_regex(data, prefixes=[storage.url_scheme])\nif all_uris and task is None:\n    raise ValueError('Resolving these URIs requires the owning Task')","typeGuard":"def resolution_possible(data, task, storage) -> bool:\n    has_uris = bool(get_all_uris_via_regex(data, prefixes=[storage.url_scheme]))\n    return not has_uris or task is not None","tryCatchPattern":"try:\n    resolved = storage.resolve_uris(data, task=task)\nexcept ValueError as e:\n    if 'Task is required' in str(e):\n        resolved = data  # leave URIs unresolved when no task context\n    else:\n        raise","preventionTips":["Carry the Task reference alongside data strings in export/import pipelines.","Pre-scan data for scheme URIs to decide whether task context is needed before calling resolve_uris.","Never call resolve_uris with task=None on data you know contains storage URIs."],"tags":["storage","uri-resolution","missing-argument"],"backgroundTag":"missing-required-task-context","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}