You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
normalize_input_files silently drops IOBase inputs despite accepting them in its type #9625
The dispatch loop, however, handles only FilePath, FileBytes, FileStream, FileUrl, Path, str, bytes, and memoryview. Everything else, including a BytesIO or an opened binary file, falls into the final else: continue:
The stream is silently absent from the returned dictionary. No warning or error is produced, so a task declared with input_files=[open("report.pdf", "rb")] or a BytesIO ends up with that file missing from its inputs.
Note that File(source=stream) already supports streams through _FileSourceCoercer (types.py:27-46), so the two entry points disagree about the same documented input type.
Reproduction
importiofromcrewai_filesimportnormalize_input_filesstream=io.BytesIO(b"streamed content")
stream.name="streamed.txt"print(normalize_input_files([stream]))
# {} on main; expected {"streamed.txt": <FileInput>}
Expected behaviour
An IOBase input should be wrapped in FileStream, as File construction does, so the stream appears in the result under its .name (or file_<index> when unnamed).
Tests
lib/crewai/tests/utilities/test_files.py adds test_normalize_file_like_object under TestNormalizeInputFiles. It fails on main with:
AssertionError: assert 'streamed.txt' in {}
and passes with the fix.
AI assistance
I used an AI coding agent to investigate, implement, and test this change, and reviewed its results. Per CONTRIBUTING.md, please apply the llm-generated label; external contributors cannot add it with my current permissions.
Confirmed — a named BytesIO and an unnamed one both come back as {}:
normalize_input_files([stream]) # {} — stream had name "streamed.txt"normalize_input_files([b"abc"]) # {'file_0': ...} — bytes still work
The dispatch loop really does fall through to else: continue for anything that isn't a path/str/bytes/memoryview, while FileSourceInput advertises IOBase and File(source=stream) coerces streams fine through _FileSourceCoercer. So the two entry points disagree on the same documented input type, and the silent drop is the worst part — nothing tells you the file never made it in. Wrapping IOBase inputs in FileStream here, the way File construction already does, lines them up.
Activity
abhi478jeetur-rgb commentedon Nov 21, 2026
Confirmed — a named
BytesIOand an unnamed one both come back as{}:The dispatch loop really does fall through to
else: continuefor anything that isn't a path/str/bytes/memoryview, whileFileSourceInputadvertisesIOBaseandFile(source=stream)coerces streams fine through_FileSourceCoercer. So the two entry points disagree on the same documented input type, and the silent drop is the worst part — nothing tells you the file never made it in. WrappingIOBaseinputs inFileStreamhere, the wayFileconstruction already does, lines them up.