Skip to content

Resolve AzureFileShareToGCSOperator directory_name alias after rendering - #70740

Open
Andrushika wants to merge 3 commits into
apache:mainfrom
Andrushika:fix-70296-azure-fileshare-directory-alias
Open

Resolve AzureFileShareToGCSOperator directory_name alias after rendering#70740
Andrushika wants to merge 3 commits into
apache:mainfrom
Andrushika:fix-70296-azure-fileshare-directory-alias

Conversation

@Andrushika

Copy link
Copy Markdown
Contributor

Resolve AzureFileShareToGCSOperator directory_name alias after rendering

Why

directory_name and directory_path are both template fields, rendered after __init__ runs. The old constructor resolved the deprecated directory_name -> directory_path alias there, on the un-rendered values, which #70296 flags.

What

Move the alias copy into render_template_fields, not execute. The alias needs to know if directory_path was passed, and with render_template_as_native_obj=True a supplied directory_path can render to None. So the check runs before rendering, where the raw values are still visible, and the copy runs after. The deprecation warning stays in __init__.

related: #70296


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) 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.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

directory_name and directory_path are both template fields, rendered after the constructor runs. Resolving the deprecated directory_name -> directory_path alias in __init__ meant the provision decision was made on the un-rendered values; under render_template_as_native_obj a supplied directory_path can render to None, so the decision has to be taken before rendering while a supplied-but-None field is still distinguishable from a missing one, and the copy has to happen after, on the real values. Keeping it in the constructor also tripped the validate-operators-init guard tracked by apache#70296.
@Andrushika

Copy link
Copy Markdown
Contributor Author

cc @shahar1

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for taking this on — moving the alias out of __init__ is the right direction, and the pre-render/post-render split is a genuinely subtle point that the second test documents well.

One blocking issue: the render_template_fields override never runs for mapped tasks, so this turns a currently-working case into a runtime failure. Details inline.

Smaller observations:

  • test_no_directory_name_deprecation_without_directory_name passes unchanged on main — it exercises pre-existing __init__ behaviour rather than anything this PR changes. Per AGENTS.md Testing Standards: "every test must fail without the PR's change... Do not add tests for pre-existing logic that was already present before the PR." (test_native_directory_path_rendering_to_none_is_not_aliased is fine — it's an explicit behaviour-preservation guard, which is the documented exception.)
  • Nit: the class docstring still says "Note that share_name, directory_path, prefix, and dest_gcs are templated" — worth adding directory_name, since making its templating actually work is what this PR is about.

This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. After you've
addressed the points above and pushed an update, an Apache Airflow
maintainer — a real person — will take the next look
at the PR. The findings cite the project's review criteria;
if you think one of them is mis-applied, please reply on the
PR and a maintainer will weigh in.

More on how Apache Airflow handles maintainer review:
contributing-docs/05_pull_requests.rst.

Comment thread providers/google/tests/unit/google/cloud/transfers/test_azure_fileshare_to_gcs.py Outdated
MappedOperator.render_template_fields calls _do_render_template_fields
on the unmapped task directly, so render_template_fields overrides never
run for mapped tasks and the alias was lost on that path. execute() runs
on both the mapped and unmapped paths, after rendering; the was-it-passed
decision stays in __init__ where the un-rendered values are visible.
@Andrushika
Andrushika requested a review from shahar1 August 3, 2026 10:10
@Andrushika

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing, Shahar! I've addressed the requested changes. Could you take another look when you have time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:providers backport-to-v3-3-test Backport to v3-3-test provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants