{"record":{"id":"bf5b67587e3aa721","repo":"HumanSignal/label-studio","slug":"url-must-be-2048-characters-or-fewer","errorCode":null,"errorMessage":"\"url\" must be 2048 characters or fewer","messagePattern":"\"url\" must be 2048 characters or fewer","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/data_import/api.py","lineNumber":394,"sourceCode":"            preannotated_from_fields=preannotated_from_fields,\n            commit_to_project=commit_to_project,\n            return_task_ids=return_task_ids,\n        )\n\n        if len(request.FILES) > 0:\n            logger.debug(f'Import from files: {request.FILES}')\n            file_upload_ids, could_be_tasks_list = create_file_uploads(request.user, project, request.FILES)\n            project_import.file_upload_ids = file_upload_ids\n            project_import.could_be_tasks_list = could_be_tasks_list\n            project_import.save(update_fields=['file_upload_ids', 'could_be_tasks_list'])\n        elif 'application/x-www-form-urlencoded' in request.content_type:\n            logger.debug(f'Import from url: {request.data.get(\"url\")}')\n            # empty url\n            url = request.data.get('url')\n            if not url:\n                raise ValidationError('\"url\" is not found in request data')\n            if len(url) > 2048:\n                raise ValidationError('\"url\" must be 2048 characters or fewer')\n            project_import.url = url\n            project_import.save(update_fields=['url'])\n        # take one task from request DATA\n        elif 'application/json' in request.content_type and isinstance(request.data, dict):\n            project_import.tasks = [request.data]\n            project_import.save(update_fields=['tasks'])\n\n        # take many tasks from request DATA\n        elif 'application/json' in request.content_type and isinstance(request.data, list):\n            project_import.tasks = request.data\n            project_import.save(update_fields=['tasks'])\n\n        # incorrect data source\n        else:\n            raise ValidationError('load_tasks: No data found in DATA or in FILES')\n\n        start_job_async_or_sync(\n            async_import_background,","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/data_import/api.py#L376-L412","documentation":"In the same urlencoded branch of async_import, after confirming 'url' is present, Label Studio enforces a maximum URL length of 2048 characters and raises this ValidationError for longer URLs. The limit guards against oversized request lines and downstream storage/column constraints.","triggerScenarios":"POST /api/projects/{id}/import with application/x-www-form-urlencoded and a 'url' value longer than 2048 characters — typically a URL embedding a very long query string or a giant data: / presigned URL with many parameters.","commonSituations":"Cloud storage presigned URLs (S3/GCS/Azure SAS) that include long signatures and expiry params; URLs that encode the whole JSON payload as a query parameter; generated signed URLs from CDNs with many options.","solutions":["Shorten the URL: host the file and share a stable short path instead of embedding data in query params","For presigned URLs, reduce signed headers/params or regenerate with fewer options","Download the file and import it as a file upload (multipart) or via application/json tasks instead","Serve the file behind a short alias/redirect on your own domain"],"exampleFix":"// before: one giant URL with embedded payload\nurl=https://example.com/import?data=%5B%7B%22text%22%3A%22...3000+chars...%22%7D%5D\n// after: upload tasks directly as JSON\nrequests.post(f'{LS_URL}/api/projects/1/import', headers=HEADERS, json=[{\"text\": \"...\"}])","handlingStrategy":"validation","validationCode":"if len(url) > 2048:\n    raise ValueError(f'url is {len(url)} chars; import a local copy of the file instead')","typeGuard":"def is_importable_url(url) -> bool:\n    return isinstance(url, str) and url.startswith(('http://', 'https://')) and len(url) <= 2048","tryCatchPattern":"try:\n    resp = requests.post(import_url, headers=H, data={'url': url})\n    resp.raise_for_status()\nexcept requests.HTTPError as e:\n    if '2048' in e.response.text:\n        fallback_to_file_upload(url)","preventionTips":["Check len(url) before sending, especially for presigned URLs","Regenerate presigned URLs with minimal signed headers/params","Prefer stable short URLs or direct file upload for large payloads"],"tags":["django","rest-framework","import","url","validation"],"backgroundTag":"url-too-long","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}