Skip to content

fix(files): skip Path() for integer FileStream names - #7627

Open
leilei3167 wants to merge 1 commit into
crewAIInc:mainfrom
leilei3167:fix/issue-7621-filestream-int-name
Open

leilei3167 wants to merge 1 commit into
crewAIInc:mainfrom
leilei3167:fix/issue-7621-filestream-int-name

Conversation

@leilei3167

Copy link
Copy Markdown

Related issue

Fixes #7621

Summary

FileStream._initialize inferred a filename by passing stream.name to Path(). Streams opened from a file descriptor expose an integer name, so construction raised TypeError before the file could be used.

Infer the filename only when name is a str or os.PathLike. Descriptor-backed streams keep the optional filename unset. An explicit filename and inference from ordinary named files are unchanged.

Verification

  • Tests added or updated for the changed behavior
  • Relevant tests and quality checks pass locally

Old red (before fix):

uv run --group dev --package crewai pytest --noconftest -n 0 \
  lib/crewai-files/tests/test_sources.py::test_filestream_accepts_integer_descriptor_name -q
# 1 failed — TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'int'

New green (after fix):

uv run --group dev --package crewai pytest --noconftest -n 0 \
  lib/crewai-files/tests/test_sources.py -q
# 3 passed

uv run --group dev --package crewai pytest --noconftest -n 0 \
  lib/crewai-files/tests/test_file_url.py lib/crewai-files/tests/test_factory.py -q
# 35 passed

uv run --group dev --package crewai ruff check \
  lib/crewai-files/src/crewai_files/core/sources.py \
  lib/crewai-files/tests/test_sources.py
# All checks passed

Additional context

AI-assisted contribution per CONTRIBUTING.md. This account cannot apply repository labels (AddLabelsToLabelable permission denied); please apply llm-generated before review.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 3497998d-2f14-49a0-886b-fb182b6ef70c

📥 Commits

Reviewing files that changed from the base of the PR and between 3831e8b and 163ef56.

📒 Files selected for processing (2)
  • lib/crewai-files/src/crewai_files/core/sources.py
  • lib/crewai-files/tests/test_sources.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

FileStream now skips filename inference for integer stream names. Named-file inference and explicit filenames remain supported. Tests cover all three cases and verify stream reads.

Changes

FileStream filename inference

Layer / File(s) Summary
Restrict filename inference and validate stream handling
lib/crewai-files/src/crewai_files/core/sources.py, lib/crewai-files/tests/test_sources.py
FileStream infers filenames only from str or os.PathLike stream names. Tests verify integer descriptor streams remain readable without a filename, named files infer their basename, and explicit filenames remain unchanged.

Priority: ➖ Normal

Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main fix: avoiding Path() conversion for integer FileStream names.
Description check ✅ Passed The description includes the related issue, explains the root cause and solution, documents verification results, and provides additional context.
Linked Issues check ✅ Passed The change satisfies #7621. FileStream._initialize calls Path(name) only when name is a str or os.PathLike. Integer descriptor names leave filename as None. The regression test verifies …
Out of Scope Changes check ✅ Passed The pull request changes only FileStream filename inference and adds tests for the linked issue behavior. The source change and all added tests support #7621.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[BUG] FileStream rejects streams with integer file-descriptor names

1 participant