{"record":{"id":"db2682fa8debf1dc","repo":"openai/openai-python","slug":"passing-both-content-and-json-data-is-not-supp","errorCode":null,"errorMessage":"Passing both `content` and `json_data` is not supported","messagePattern":"Passing both `content` and `json_data` is not supported","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/openai/_base_client.py","lineNumber":584,"sourceCode":"            # request based on the truthiness of the \"files\" argument.\n            # This gets around that issue by generating a dict value that\n            # evaluates to true.\n            #\n            # https://github.com/encode/httpx/discussions/2399#discussioncomment-3814186\n            if not files:\n                files = cast(HttpxRequestFiles, ForceMultipartDict())\n\n        prepared_url = self._prepare_url(options.url)\n        # preserve hard-coded query params from the url\n        if params and prepared_url.query:\n            params = {**dict(prepared_url.params.items()), **params}\n            prepared_url = prepared_url.copy_with(raw_path=prepared_url.raw_path.split(b\"?\", 1)[0])\n\n        is_body_allowed = options.method.lower() != \"get\"\n\n        if is_body_allowed:\n            if options.content is not None and json_data is not None:\n                raise TypeError(\"Passing both `content` and `json_data` is not supported\")\n            if options.content is not None and files is not None:\n                raise TypeError(\"Passing both `content` and `files` is not supported\")\n            if options.content is not None:\n                kwargs[\"content\"] = options.content\n            elif isinstance(json_data, bytes):\n                kwargs[\"content\"] = json_data\n            elif not files:\n                # Don't set content when JSON is sent as multipart/form-data,\n                # since httpx's content param overrides other body arguments\n                kwargs[\"content\"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None\n            kwargs[\"files\"] = files\n        else:\n            headers.pop(\"Content-Type\", None)\n            kwargs.pop(\"data\", None)\n\n        timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout\n        request_url = str(prepared_url)\n        request_headers = list(headers.multi_items())","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_base_client.py#L566-L602","documentation":"The OpenAI Python SDK raises this ValueError when await client.vector_stores.file_batches.cancel() (async) is called with a falsy vector_store_id. It is a fast-fail client-side guard; no HTTP request is made when the store identifier is empty or None.","triggerScenarios":"Awaiting cancel(vector_store_id='', batch_id='vsfb_...') on the async resource, typically because the owning store's ID was never captured or was emptied by earlier logic.","commonSituations":"Cancellation code paths run from webhooks or background workers where the store reference was not passed along, or refactors that renamed variables holding the ID.","solutions":["Thread the 'vs_...' store ID through to the cancellation code; verify it is set before awaiting cancel.","When handling webhooks/jobs, validate that both vector_store_id and batch_id fields are present and non-empty before acting on them.","Log the offending values at the call site to pinpoint where the ID was lost."],"exampleFix":"# before\nawait client.vector_stores.file_batches.cancel(vector_store_id=store, batch_id=bid)  # store is None\n\n# after\nif not store:\n    raise ValueError(\"cannot cancel batch: vector_store_id missing\")\nawait client.vector_stores.file_batches.cancel(vector_store_id=store, batch_id=bid)","handlingStrategy":"validation","validationCode":"if not vector_store_id or not batch_id:\n    raise ValueError(\"cancel requires both vector_store_id and batch_id\")\nawait client.vector_stores.file_batches.cancel(vector_store_id=vector_store_id, batch_id=batch_id)","typeGuard":"def has_required_ids(vs: object, bid: object) -> bool:\n    return (\n        isinstance(vs, str) and vs.startswith(\"vs_\")\n        and isinstance(bid, str) and bid.startswith(\"vsfb_\")\n    )","tryCatchPattern":"try:\n    await client.vector_stores.file_batches.cancel(vector_store_id=vs, batch_id=bid)\nexcept ValueError:\n    # argument bug — fix caller; never retry with the same empty values\n    raise","preventionTips":["Pass full (store_id, batch_id) pairs through job queues and webhooks.","Log both IDs at the cancellation call site for diagnosability."],"tags":["openai","vector-stores","file-batches","async","validation","python"],"backgroundTag":"empty-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}