Skip to content

Keep S3DeleteObjectsOperator validation in __init__, narrow to ValueError - #70359

Merged
shahar1 merged 2 commits into
apache:mainfrom
AmoghAtreya:fix/70296-operators-init-s3-and-gce
Jul 30, 2026
Merged

Keep S3DeleteObjectsOperator validation in __init__, narrow to ValueError#70359
shahar1 merged 2 commits into
apache:mainfrom
AmoghAtreya:fix/70296-operators-init-s3-and-gce

Conversation

@AmoghAtreya

@AmoghAtreya AmoghAtreya commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Description

related: #70296 — burn-down of __init__-time validation exemptions.

Changes Made (S3DeleteObjectsOperator, amazon):

  • Rewrote the __init__ argument-combination guard with explicit is not None
    checks so the validate-operators-init hook recognizes it (the old
    comprehension-based check read as a false positive). The logic is unchanged —
    equivalent on every input combination.
  • Narrowed the raised exception from AirflowException to ValueError
    (parse-time only; the execute()-time guard is deliberately retained
    unchanged as a safety net for templated keys rendering to None).
  • Removed the S3DeleteObjectsOperator entry from
    scripts/ci/prek/validate_operators_init_exemptions.txt and updated the
    generated/known_airflow_exceptions.txt count (5 → 4).
  • Updated the unit test to expect ValueError.

works on: #70296


Was generative AI tooling used to co-author this PR?
  • Yes (Claude Sonnet)

Generated-by: Claude following the guidelines


@AmoghAtreya

Copy link
Copy Markdown
Contributor Author

Sorry, the issue has been linked to the PR and should be unlinked to prevent the issue from closing. My apologies.

@shahar1 shahar1 removed the backport-to-v3-3-test Backport to v3-3-test label Jul 24, 2026
@shahar1 shahar1 changed the title fix(providers): move S3 and GCE operator template validation out of __init__ (#70296) Move S3 and GCE operator template validation out of __init__ (#70296) Jul 24, 2026
@shahar1

shahar1 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Sorry, the issue has been linked to the PR and should be unlinked to prevent the issue from closing. My apologies.

No worries, it's a matter of changing the "resolves:" into "related:" :)
Also, I've modfied the title - we don't use conventional commits.
Please note that you have a failure in the static checks.

@AmoghAtreya

Copy link
Copy Markdown
Contributor Author

Thanks for updating the title. Will commit the code to fix the failure in the static checks after they all finish running. The Tests (AMD) check was failing due to an incorrect number in the code.

@AmoghAtreya
AmoghAtreya force-pushed the fix/70296-operators-init-s3-and-gce branch from 42f5c65 to 08f503f Compare July 24, 2026 08:20
@AmoghAtreya

Copy link
Copy Markdown
Contributor Author

@shahar1 please let me know if there's anything you want me to change in this PR. I fixed all the static bugs and checks from a few days ago.

@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.

Could you please focus the PR on a single provider? (I know that GCP compute operators are being handled in another PR, so maybe just focus on S3DeleteObjectsOperator)

@AmoghAtreya

AmoghAtreya commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Reverted changes! This PR is only focused on S3 now. @shahar1

@AmoghAtreya

Copy link
Copy Markdown
Contributor Author

Checks just passed. Please let me know what you think!

@AmoghAtreya AmoghAtreya changed the title Move S3 and GCE operator template validation out of __init__ (#70296) Move S3 operator template validation out of __init__ (#70296) Jul 27, 2026
Comment thread providers/amazon/src/airflow/providers/amazon/aws/operators/s3.py
@AmoghAtreya

Copy link
Copy Markdown
Contributor Author

The checks will pass once #70505 gets merged due to the condition being introduced there.

@AmoghAtreya

Copy link
Copy Markdown
Contributor Author

@shahar1 since #70505 was merged, can you please run the static checks again? That way, I can ensure this passes all tests and be ready for the next code review from your side!

@shahar1

shahar1 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@shahar1 since #70505 was merged, can you please run the static checks again? That way, I can ensure this passes all tests and be ready for the next code review from your side!

Please merge from/rebase onto main, and push to your branch. It will retrigger the CI with latest changes (I'll approve if necessary).

@AmoghAtreya
AmoghAtreya requested a review from shahar1 July 29, 2026 02:19
@AmoghAtreya
AmoghAtreya force-pushed the fix/70296-operators-init-s3-and-gce branch from 43f0541 to 7a1b525 Compare July 29, 2026 06:46
@AmoghAtreya

Copy link
Copy Markdown
Contributor Author

Since all checks are passing, please let me know next steps @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.

Great work!
Congrats for your first PRs, looking forward fore more :)

@shahar1 shahar1 changed the title Move S3 operator template validation out of __init__ (#70296) Narrow S3DeleteObjectsOperator init validation error to ValueError Jul 30, 2026
@shahar1 shahar1 changed the title Narrow S3DeleteObjectsOperator init validation error to ValueError Keep S3DeleteObjectsOperator validation in __init__, narrow to ValueError Jul 30, 2026
@shahar1

shahar1 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@AmoghAtreya
FYI, in future PRs - please note that you changed AirflowException to ValueError.
Not sure if it was intended or not, in this case it's ok - but it shouldn't be done for AirflowException raised within execute() as it is considered as a breaking-change due to retriable behavior that depends on these exceptions.

@shahar1
shahar1 merged commit f781f8b into apache:main Jul 30, 2026
83 checks passed
@boring-cyborg

boring-cyborg Bot commented Jul 30, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@AmoghAtreya

Copy link
Copy Markdown
Contributor Author

Great work! Congrats for your first PRs, looking forward fore more :)

Thank you so much for working with me through this and reviewing my code. Really appreciate that you took the time to help me out and provide feedback! Looking forward to contributing more.

atikulmunna added a commit to atikulmunna/airflow that referenced this pull request Jul 31, 2026
Addresses review feedback on apache#70723. The check asks whether `match_glob`
was passed rather than inspecting its rendered value, so per the false
positives section of apache#70296 it is a provision check and belongs in the
constructor. Moving it to `execute()` was wrong on two counts: with
`render_template_as_native_obj=True` a provided field can render to None,
and raising per task instance hides a static authoring mistake that a Dag
import error would surface immediately.

Rewrite it in place instead, using `is not None` polarity rather than a
truthiness test on the un-rendered string, and narrow `AirflowException`
to `ValueError` to match apache#70359. Since apache#70505 narrowed the hook to sanction
provision checks written this way, the exemption entry still goes.

Narrowing removes the file's only `raise AirflowException`, so drop its
entry from generated/known_airflow_exceptions.txt to keep the
check-no-new-airflow-exceptions allowlist in sync.

related: apache#70296
Signed-off-by: atikulmunna <atikul.munna@northsouth.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:providers provider:amazon AWS/Amazon - related issues provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants