Skip to content

fix(task-sdk): exclude pathlib.Path from resolve() call in templater#63306

Merged
eladkal merged 1 commit into
apache:mainfrom
YoannAbriel:fix/issue-55412
Mar 15, 2026
Merged

fix(task-sdk): exclude pathlib.Path from resolve() call in templater#63306
eladkal merged 1 commit into
apache:mainfrom
YoannAbriel:fix/issue-55412

Conversation

@YoannAbriel

Copy link
Copy Markdown
Contributor

Closes: #55412

pathlib.Path.resolve() takes an optional strict parameter, not a context dict. The templater's duck-typed getattr(value, "resolve", None) check matches pathlib objects, then calls path.resolve(context) — the dict is interpreted as strict=True, raising FileNotFoundError if the path doesn't exist.

Added an isinstance(value, os.PathLike) guard to skip pathlib-like objects before the resolve check.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4, claude-opus-4-6)

Generated-by: Claude Code (Opus 4, claude-opus-4-6) following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.

@YoannAbriel YoannAbriel force-pushed the fix/issue-55412 branch 3 times, most recently from d1a8687 to 6ba2449 Compare March 13, 2026 19:02
…later

pathlib.Path objects have a resolve() method for filesystem resolution
(strict parameter), which conflicts with the Resolvable.resolve(context)
protocol used by the templater. When a pathlib.Path subclass is passed as
a templated field value, the templater incorrectly calls
path.resolve(context), where the context dict is interpreted as
strict=True, causing FileNotFoundError if the path doesn't exist.

This adds an isinstance(value, os.PathLike) guard before calling
resolve() to ensure pathlib.Path objects are returned as-is.

Closes: apache#55412
@eladkal eladkal added this to the Airflow 3.1.9 milestone Mar 15, 2026
@eladkal eladkal merged commit 23dec8d into apache:main Mar 15, 2026
197 of 199 checks passed
github-actions Bot pushed a commit that referenced this pull request Mar 15, 2026
…ve() in templater (#63306)

pathlib.Path objects have a resolve() method for filesystem resolution
(strict parameter), which conflicts with the Resolvable.resolve(context)
protocol used by the templater. When a pathlib.Path subclass is passed as
a templated field value, the templater incorrectly calls
path.resolve(context), where the context dict is interpreted as
strict=True, causing FileNotFoundError if the path doesn't exist.

This adds an isinstance(value, os.PathLike) guard before calling
resolve() to ensure pathlib.Path objects are returned as-is.
(cherry picked from commit 23dec8d)

Co-authored-by: Yoann <60654707+YoannAbriel@users.noreply.github.com>
Closes: #55412
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-1-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-1-test PR Link

eladkal pushed a commit that referenced this pull request Mar 15, 2026
…ve() in templater (#63306) (#63633)

pathlib.Path objects have a resolve() method for filesystem resolution
(strict parameter), which conflicts with the Resolvable.resolve(context)
protocol used by the templater. When a pathlib.Path subclass is passed as
a templated field value, the templater incorrectly calls
path.resolve(context), where the context dict is interpreted as
strict=True, causing FileNotFoundError if the path doesn't exist.

This adds an isinstance(value, os.PathLike) guard before calling
resolve() to ensure pathlib.Path objects are returned as-is.
(cherry picked from commit 23dec8d)


Closes: #55412

Co-authored-by: Yoann <60654707+YoannAbriel@users.noreply.github.com>
@YoannAbriel YoannAbriel deleted the fix/issue-55412 branch March 15, 2026 13:05
vatsrahul1001 pushed a commit that referenced this pull request Mar 25, 2026
…ve() in templater (#63306) (#63633)

pathlib.Path objects have a resolve() method for filesystem resolution
(strict parameter), which conflicts with the Resolvable.resolve(context)
protocol used by the templater. When a pathlib.Path subclass is passed as
a templated field value, the templater incorrectly calls
path.resolve(context), where the context dict is interpreted as
strict=True, causing FileNotFoundError if the path doesn't exist.

This adds an isinstance(value, os.PathLike) guard before calling
resolve() to ensure pathlib.Path objects are returned as-is.
(cherry picked from commit 23dec8d)


Closes: #55412

Co-authored-by: Yoann <60654707+YoannAbriel@users.noreply.github.com>
abhijeets25012-tech pushed a commit to abhijeets25012-tech/airflow that referenced this pull request Apr 9, 2026
…later (apache#63306)

pathlib.Path objects have a resolve() method for filesystem resolution
(strict parameter), which conflicts with the Resolvable.resolve(context)
protocol used by the templater. When a pathlib.Path subclass is passed as
a templated field value, the templater incorrectly calls
path.resolve(context), where the context dict is interpreted as
strict=True, causing FileNotFoundError if the path doesn't exist.

This adds an isinstance(value, os.PathLike) guard before calling
resolve() to ensure pathlib.Path objects are returned as-is.

Closes: apache#55412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:task-sdk type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Airflow 3.x templating calls resolve() on Path-like objects with context argument, causing FileNotFoundError in custom subclasses

3 participants