Skip to content

fix: URL coercion regression for plain str inputs#2870

Closed
erayack wants to merge 1 commit intoreplicate:mainfrom
erayack:fix-url-coercion-2868-str-regression
Closed

fix: URL coercion regression for plain str inputs#2870
erayack wants to merge 1 commit intoreplicate:mainfrom
erayack:fix-url-coercion-2868-str-regression

Conversation

@erayack
Copy link

@erayack erayack commented Mar 26, 2026

Summary

  • replace file-field detection with explicit per-field coercion targets (File/Path)
  • only coerce URL-like strings for explicitly typed File/Path fields (including Optional[...] and list[...] forms)
  • keep explicit str fields untouched
  • restore legacy fallback when typing.get_type_hints() fails by coercing URL-like strings via Path.validate()

Why

Issue #2868 identified a regression where plain str inputs were coerced as file/path values. This change narrows coercion to explicit typing while preserving prior fallback behavior if type hint resolution fails.

Notes

  • no public API changes
  • behavior is stricter when type hints resolve, and backward-compatible when hint resolution fails

@erayack erayack requested a review from a team as a code owner March 26, 2026 18:44
@erayack erayack changed the title Fix URL coercion regression for plain str inputs fix: URL coercion regression for plain str inputs Mar 26, 2026
@markphelps
Copy link
Contributor

thank you for the contribution @erayack !! going to close this in favor of #2872 as we discussed, but looking forward to the PR for the PEP 604 union handling

@markphelps markphelps closed this Mar 26, 2026
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.

2 participants