[BUG] FileStream rejects streams with integer file-descriptor names
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 58.8k
- Forks
- 8.5k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 109
Description
This is an AI-generated issue. I requested the required llm-generated label during creation and retried adding it, but GitHub rejected AddLabelsToLabelable because my account lacks permission. Please apply the label so the contribution can follow the project policy.
Description
FileStream rejects a valid binary stream opened from a file descriptor when filename is omitted. Such streams expose an integer name; filename inference passes that integer to Path and raises TypeError before the file can be supplied to an agent.
Steps to Reproduce
Open a temporary binary file, reopen its descriptor as a binary stream, and construct FileStream with its default optional filename.
Screenshots/Code snippets
from tempfile import TemporaryFile
from crewai_files import FileStream
with TemporaryFile() as original:
original.write(b"A file supplied to an agent.")
original.seek(0)
with open(original.fileno(), "rb", closefd=False) as stream:
source = FileStream(stream=stream)
assert source.read() == b"A file supplied to an agent."
Expected behavior
The stream should remain usable with its optional filename unset. An explicitly supplied filename and filename inference from ordinary named files should keep working.
Evidence
Current main (3831e8b6c86f78cb3cde18ebf7be0d197b958f0e) raises:
File "crewai_files/core/sources.py", in _initialize
self.filename = Path(name).name
TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'int'
Operating System
Windows.
Python Version
3.13.13.
crewAI Version
Standalone crewai-files 1.15.22 at the main commit above, with Pydantic 2.13.5. The crewai package is not needed for this reproduction.
crewAI Tools Version
Not used by this standalone file-handling reproduction.
Virtual Environment
Venv, created with uv.
Possible Solution
Infer the filename when the stream's name is a string or path-like value. Preserve the optional filename for descriptor-backed streams.
Additional context
The failure requires no model API or remote tool provider.
This issue was prepared with Codex collaboration as part of an Astra Ultra-based automated PR project contributing to the open-source community.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in crewai_files/core/sources.py at _initialize and reproduce the failure with a descriptor-backed binary stream whose name is an integer. Done means FileStream remains usable with the optional filename unset, while explicitly supplied filenames and ordinary named-file inference continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100