Skip to content

Fix File helper extension handling#4531

Merged
zzstoatzz merged 1 commit into
PrefectHQ:mainfrom
VectorPeak:fix
Jul 21, 2026
Merged

Fix File helper extension handling#4531
zzstoatzz merged 1 commit into
PrefectHQ:mainfrom
VectorPeak:fix

Conversation

@VectorPeak

Copy link
Copy Markdown
Contributor

Description

Preserve explicit extensions when data-backed File helpers build their resource URI.

Closes #4530

Before this change, File(data=bx, format=pdf, name=report.pdf) produced file:///report.pdf.pdf. The fix keeps caller-provided names with an existing suffix unchanged, while preserving the existing fallback that appends the inferred subtype for names without a suffix.

The affected call chain is a tool returning File -> _convert_to_content() -> File.to_resource_content(). Path-backed files, data-backed files without a custom name, and the existing text/blob resource-content split are unchanged.

Validation:

  • uv sync
  • PYTHONUTF8=1 uv run --frozen pytest tests/utilities/test_types.py -q (82 passed)
  • PYTHONUTF8=1 uv run pytest tests/tools/tool/test_content.py tests/tools/tool/test_tool.py tests/server/tasks/test_task_return_types.py tests/server/providers/local_provider_tools/test_local_provider_tools.py -q (132 passed)
  • PYTHONUTF8=1 uv run --frozen ruff format --check fastmcp_slim/fastmcp/utilities/types.py tests/utilities/test_types.py
  • PYTHONUTF8=1 uv run --frozen ruff check fastmcp_slim/fastmcp/utilities/types.py tests/utilities/test_types.py
  • git diff --check

Local full-suite notes:

  • PYTHONUTF8=1 uv run prek --refresh run --all-files reached the hooks successfully after refreshing cache, but ty check fails on Windows with existing fcntl.flock / LOCK_EX / LOCK_UN unresolved-attribute diagnostics in tests/utilities/json_schema_type/test_real_world_schemas.py.
  • PYTHONUTF8=1 uv run pytest -n auto fails in this Windows environment on unrelated environment/platform paths, including missing npx for conformance, symlink privilege WinError 1314, and xdist worker crashes.

Contribution type

  • Bug fix (simple, well-scoped fix for a clearly broken behavior)
  • Documentation improvement
  • Enhancement (maintainers typically implement enhancements — see CONTRIBUTING.md)

Checklist

  • This PR addresses an existing issue (or fixes a self-evident bug)
  • I have read CONTRIBUTING.md
  • I have added tests that cover my changes
  • I have run uv run prek run --all-files and all checks pass
  • I have self-reviewed my changes
  • If I used an LLM, it followed the repo's contributing conventions (not generic output)

@github-actions

This comment has been minimized.

@github-actions github-actions Bot closed this Jul 18, 2026
@marvin-context-protocol marvin-context-protocol Bot added the bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. label Jul 20, 2026
@github-actions github-actions Bot reopened this Jul 21, 2026
Preserve explicit suffixes when building data-backed File resource URIs, while keeping the inferred-extension fallback for names without a suffix.

Closes PrefectHQ#4530

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>

@zzstoatzz zzstoatzz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@zzstoatzz
zzstoatzz merged commit 74b8f1b into PrefectHQ:main Jul 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data-backed File helper duplicates explicit filename extensions

2 participants