Skip to content

Read PathLike inside (name, content) file tuples - #1788

Draft
kilanassah wants to merge 1 commit into
anthropics:mainfrom
kilanassah:fix/1769-pathlike-in-file-tuple
Draft

Read PathLike inside (name, content) file tuples#1788
kilanassah wants to merge 1 commit into
anthropics:mainfrom
kilanassah:fix/1769-pathlike-in-file-tuple

Conversation

@kilanassah

@kilanassah kilanassah commented Jul 30, 2026

Copy link
Copy Markdown

Fixes #1769.

Check tuple inputs before generic FileContent inputs in _transform_file (and the async version).

Path is valid file content, but the current check order returns a (filename, Path) tuple without reading the inner path, so httpx later calls .read() on it and raises AttributeError.

Adds sync and async regression tests for filename + Path tuples.

`_transform_file` checked `is_file_content` before `is_tuple_t`, but
`is_file_content` returns True for any tuple. A `(name, Path)` tuple
therefore matched the file-content branch, was not itself a PathLike, and
was returned unchanged — leaving the Path for httpx to call `.read()` on,
raising `AttributeError: 'WindowsPath' object has no attribute 'read'`.

Check `is_tuple_t` first so the tuple's inner content is read via
`read_file_content`. Applies to both sync and async transforms. Adds
regression tests covering a (name, Path) tuple.

Fixes anthropics#1769
@kilanassah
kilanassah force-pushed the fix/1769-pathlike-in-file-tuple branch from 1aba085 to dda4491 Compare July 30, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'WindowsPath' object has no attribute 'read'

1 participant