{"record":{"id":"614e7d3f234ce70e","repo":"openai/openai-python","slug":"max-retries-cannot-be-none-if-you-want-to-disable","errorCode":null,"errorMessage":"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `openai.DEFAULT_MAX_RETRIES`","messagePattern":"max_retries cannot be None\\. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math\\.inf` or a very high number; if you want the default behavior, pass `openai\\.DEFAULT_MAX_RETRIES`","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/openai/_base_client.py","lineNumber":415,"sourceCode":"        base_url: str | URL,\n        _strict_response_validation: bool,\n        max_retries: int = DEFAULT_MAX_RETRIES,\n        timeout: float | Timeout | None = DEFAULT_TIMEOUT,\n        custom_headers: Mapping[str, str] | None = None,\n        custom_query: Mapping[str, object] | None = None,\n    ) -> None:\n        self._version = version\n        self._base_url = self._enforce_trailing_slash(normalize_httpx_url(base_url))\n        self.max_retries = max_retries\n        self.timeout = timeout\n        self._custom_headers = custom_headers or {}\n        self._custom_query = custom_query or {}\n        self._strict_response_validation = _strict_response_validation\n        self._idempotency_header = None\n        self._platform: Platform | None = None\n\n        if max_retries is None:  # pyright: ignore[reportUnnecessaryComparison]\n            raise TypeError(\n                \"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `openai.DEFAULT_MAX_RETRIES`\"\n            )\n\n    def _enforce_trailing_slash(self, url: URL) -> URL:\n        if url.raw_path.endswith(b\"/\"):\n            return url\n        return url.copy_with(raw_path=url.raw_path + b\"/\")\n\n    def _make_status_error_from_response(\n        self,\n        response: httpx2.Response,\n    ) -> APIStatusError:\n        if response.is_closed and not response.is_stream_consumed:\n            # We can't read the response body as it has been closed\n            # before it was read. This can happen if an event hook\n            # raises a status error.\n            body = None\n            err_msg = f\"Error code: {response.status_code}\"","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_base_client.py#L397-L433","documentation":"The OpenAI Python SDK raises this ValueError when await client.vector_stores.file_batches.create() (async) is called with a falsy vector_store_id. Since the batch is a sub-resource of a vector store, a valid 'vs_...' identifier is required to build the POST /vector_stores/{vector_store_id}/file_batches URL.","triggerScenarios":"Awaiting create(vector_store_id='') or vector_store_id=None on AsyncVectorStoreFileBatches, commonly when the store was supposed to be created earlier but that step failed or was skipped.","commonSituations":"Chained async flows where the store creation result was not awaited or its ID not extracted, env-based store IDs that are unset, or error paths that continue to the batch step after a failed store creation.","solutions":["Ensure the vector store exists first: store = await client.vector_stores.create(name=...), then pass store.id.","Check that earlier steps in your async pipeline succeeded before creating file batches; don't swallow exceptions from store creation.","Validate the ID variable is a non-empty string before the call."],"exampleFix":"# before\nbatch = await client.vector_stores.file_batches.create(vector_store_id=store_id, file_ids=[file.id])  # store_id is None\n\n# after\nstore = await client.vector_stores.create(name=\"docs\")\nbatch = await client.vector_stores.file_batches.create(vector_store_id=store.id, file_ids=[file.id])","handlingStrategy":"validation","validationCode":"if not vector_store_id:\n    raise ValueError(\"vector_store_id is required; create the store first\")\nbatch = await client.vector_stores.file_batches.create(vector_store_id=vector_store_id, file_ids=file_ids)","typeGuard":"def is_valid_vector_store_id(v: object) -> bool:\n    return isinstance(v, str) and v.startswith(\"vs_\") and len(v) > 3","tryCatchPattern":null,"preventionTips":["Await and extract .id from store creation before creating batches.","Fail the whole pipeline when the store-creation step errors; do not continue."],"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"}