Summary
PathLike upload content works when passed directly, but fails when used as the content element inside multipart upload tuples such as ("custom.txt", Path("input.jsonl")).
The README documents file uploads as accepting bytes, PathLike, or a tuple of (filename, contents, media type), and the internal FileTypes aliases model tuple contents as FileContent, which includes PathLike.
Expected behavior
The SDK should accept PathLike consistently in documented file upload shapes, including tuple inputs where the second element is file contents.
Reproduction shape
from pathlib import Path
from openai._files import to_httpx_files
to_httpx_files({"file": ("custom.txt", Path("README.md"))})
Actual behavior
The tuple is treated as final file content before the tuple branch can normalize the second element. The PathLike value is passed through to httpx, which later expects file-like behavior and can fail with an error such as AttributeError: 'WindowsPath' object has no attribute 'read'.
Impact
Users following the documented tuple upload interface cannot combine a custom filename, media type, or headers with path-like file content.
Proposed fix
Normalize upload tuples before treating values as final file content, so the tuple content element is converted through the same PathLike reading path used for direct file inputs.
I have a focused patch ready and would like to be assigned to this issue.
Summary
PathLikeupload content works when passed directly, but fails when used as the content element inside multipart upload tuples such as("custom.txt", Path("input.jsonl")).The README documents file uploads as accepting
bytes,PathLike, or a tuple of(filename, contents, media type), and the internalFileTypesaliases model tuple contents asFileContent, which includesPathLike.Expected behavior
The SDK should accept
PathLikeconsistently in documented file upload shapes, including tuple inputs where the second element is file contents.Reproduction shape
Actual behavior
The tuple is treated as final file content before the tuple branch can normalize the second element. The
PathLikevalue is passed through to httpx, which later expects file-like behavior and can fail with an error such asAttributeError: 'WindowsPath' object has no attribute 'read'.Impact
Users following the documented tuple upload interface cannot combine a custom filename, media type, or headers with path-like file content.
Proposed fix
Normalize upload tuples before treating values as final file content, so the tuple content element is converted through the same
PathLikereading path used for direct file inputs.I have a focused patch ready and would like to be assigned to this issue.