{"record":{"id":"ececc10acda3bd98","repo":"docling-project/docling","slug":"submit-batch-received-both-target-and-targets","errorCode":null,"errorMessage":"submit_batch() received both 'target' and 'targets'; supply only one.","messagePattern":"submit_batch\\(\\) received both 'target' and 'targets'; supply only one\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"docling/service_client/_async_client.py","lineNumber":316,"sourceCode":"\n    async def submit_batch(\n        self,\n        sources: Sequence[BatchSourceRequestInput],\n        target: BatchTargetRequestInput | None = None,\n        output_formats: list[OutputFormat] | None = None,\n        options: ConvertDocumentsRequestOptions | None = None,\n        headers: dict[str, str] | None = None,\n        *,\n        targets: list[BatchTargetRequestInput] | None = None,\n    ) -> (\n        AsyncConversionJob[PresignedUrlConvertDocumentResponse]\n        | AsyncConversionJob[PresignedUrlConvertResponse]\n    ):\n        assert self._async_client is not None, \"client not open — use async with\"\n        if target is None and targets is None:\n            raise ValueError(\"submit_batch() requires either 'target' or 'targets'.\")\n        if target is not None and targets is not None:\n            raise ValueError(\n                \"submit_batch() received both 'target' and 'targets'; supply only one.\"\n            )\n        payload: dict[str, Any] = {\"sources\": sources}\n        if targets is not None:\n            payload[\"targets\"] = targets\n        else:\n            payload[\"target\"] = target\n        request = BatchConvertSourcesRequest.model_validate(payload)\n        resolved = self._resolve_options(\n            options=options,\n            max_num_pages=None,\n            max_file_size=None,\n            page_range=None,\n        )\n        # Use the first effective target for output-format hint.\n        first_target = (request.targets or [request.target])[0]\n        submit_options = self._options_for_output_formats(\n            resolved.options,","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/service_client/_async_client.py#L298-L334","documentation":"submit_batch() on the async service client accepts either 'target' (single target) or keyword-only 'targets' (list), never both. Supplying both is ambiguous — the API payload would need to choose one 'target'/'targets' field — so the client raises ValueError before building the BatchConvertSourcesRequest. This is a caller-side API misuse error, not a server error.","triggerScenarios":"Calling submit_batch(sources=..., target=..., targets=[...]) with both populated; refactoring code from single-target to multi-target and leaving the old target= argument in place; framework code that forwards **kwargs containing target while also passing targets explicitly.","commonSituations":"Migrating an existing submit_batch call to the plural API without removing the old argument; generic wrapper functions that pass all options through; IDE autocompletion adding both parameters.","solutions":["Keep exactly one of the two: drop target= when migrating to targets=[...], or vice versa.","If wrapping submit_batch, decide which form your wrapper exposes and forward only that parameter.","Add a unit assertion in wrappers that never both are set."],"exampleFix":"# before\njob = await client.submit_batch(sources=s, target=t, targets=[t, t2])\n\n# after\njob = await client.submit_batch(sources=s, targets=[t, t2])","handlingStrategy":"validation","validationCode":"assert not (target is not None and targets is not None), 'pass only one of target/targets'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When migrating to targets=[...], delete the old target= argument.","Avoid **kwargs forwarding around submit_batch; be explicit."],"tags":["service-client","async","validation","batch","api-misuse"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}