{"record":{"id":"c3692925a0ec5bb7","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-container-id-but-c36929","errorCode":null,"errorMessage":"Expected a non-empty value for `container_id` but received {container_id!r}","messagePattern":"Expected a non-empty value for `container_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/containers/files/files.py","lineNumber":92,"sourceCode":"\n        You can send either a multipart/form-data request with the raw file content, or\n        a JSON request with a file ID.\n\n        Args:\n          file: The File object (not file name) to be uploaded.\n\n          file_id: Name of the file to create.\n\n          extra_headers: Send extra headers\n\n          extra_query: Add additional query parameters to the request\n\n          extra_body: Add additional JSON properties to the request\n\n          timeout: Override the client-level default timeout for this request, in seconds\n        \"\"\"\n        if not container_id:\n            raise ValueError(f\"Expected a non-empty value for `container_id` but received {container_id!r}\")\n        body = deepcopy_with_paths(\n            {\n                \"file\": file,\n                \"file_id\": file_id,\n            },\n            [[\"file\"]],\n        )\n        files = extract_files(cast(Mapping[str, object], body), paths=[[\"file\"]])\n        if files:\n            # It should be noted that the actual Content-Type header that will be\n            # sent to the server will contain a `boundary` parameter, e.g.\n            # multipart/form-data; boundary=---abc--\n            extra_headers = {\"Content-Type\": \"multipart/form-data\", **(extra_headers or {})}\n        return self._post(\n            path_template(\"/containers/{container_id}/files\", container_id=container_id),\n            body=maybe_transform(body, file_create_params.FileCreateParams),\n            files=files,\n            options=make_request_options(","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/containers/files/files.py#L74-L110","documentation":"The OpenAI SDK requires a non-empty `container_id` to build the upload URL; client.containers.files.create raises ValueError before any HTTP request when it is falsy. The method backs create_and_poll and upload helpers, so those fail the same way.","triggerScenarios":"Calling client.containers.files.create(container_id='', file=...) or the upload/create_and_poll helpers with a missing container id.","commonSituations":"Uploading into a container whose creation failed or whose id was not captured; using a placeholder string like '' during development.","solutions":["Create the container first and pass its id: container = client.containers.create(...); then files.create(container.id, ...)","Assert the container id is non-empty before uploading","Check that the container creation response actually contains an id"],"exampleFix":"// before\nfile = client.containers.files.create(container_id=\"\", file=open('a.pdf','rb'))\n// after\ncontainer = client.containers.create()\nfile = client.containers.files.create(container_id=container.id, file=open('a.pdf','rb'))","handlingStrategy":"validation","validationCode":"assert container_id, \"create the container first and pass container.id\"\nfile = client.containers.files.create(container_id=container_id, file=file_obj)","typeGuard":"def is_non_empty_str(v: object) -> bool:\n    return isinstance(v, str) and bool(v)","tryCatchPattern":"try:\n    file = client.containers.files.create(container_id=container_id, file=f)\nexcept ValueError as e:\n    if 'container_id' in str(e):\n        raise RuntimeError('container not initialized') from e\n    raise","preventionTips":["Always create the container before uploading into it","Capture container.id from the create response explicitly","Fail fast on empty config values during service startup"],"tags":["openai","python","validation","containers","file-upload"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}