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.

dabla pushed a commit to dabla/airflow that referenced this pull request Aug 14, 2026
DhanushAnegondi pushed a commit to DhanushAnegondi/airflow that referenced this pull request Aug 14, 2026
match_glob is a template field, so its value is not available until
Jinja rendering happens on the worker, well after __init__ has run. The
guard that rejects match_glob on an unsupported google provider tested
it for truthiness, which the validate-operators-init prek hook flags.

The check only asks whether the argument was supplied; it never
inspects the value. Per the false-positive guidance on apache#70296 that
makes it a provision check, which is fixed in place rather than moved
to execute(). Moving it would break the check under
render_template_as_native_obj=True, where a supplied field can render
to None and so becomes indistinguishable from an omitted one, and would
defer a static authoring mistake from Dag parse time to every task
instance and retry.

Switching to an explicit is not None comparison changes one case:
match_glob="" is now rejected on a google provider older than 10.3.0,
where truthiness previously read the supplied empty string as absent.
An empty glob is not a valid pattern and was never honoured on those
versions.

Narrow the raised exception from AirflowException to ValueError, which
is what an invalid argument warrants, and drop the file from
generated/known_airflow_exceptions.txt accordingly. This follows the
merged apache#70359 precedent for S3DeleteObjectsOperator, which made the
same one-for-one change to the same four kinds of file.

Also remove the class from the prek exemption list, since the hook
fails on stale entries, and add tests covering supplied, empty-string
and omitted match_glob.

Related: apache#70296
DhanushAnegondi pushed a commit to DhanushAnegondi/airflow that referenced this pull request Aug 14, 2026
match_glob is a template field, so its value is not available until
Jinja rendering happens on the worker, well after __init__ has run. The
guard that rejects match_glob on an unsupported google provider tested
it for truthiness, which the validate-operators-init prek hook flags.

The check only asks whether the argument was supplied; it never
inspects the value. Per the false-positive guidance on apache#70296 that
makes it a provision check, which is fixed in place rather than moved
to execute(). Moving it would break the check under
render_template_as_native_obj=True, where a supplied field can render
to None and so becomes indistinguishable from an omitted one, and would
defer a static authoring mistake from Dag parse time to every task
instance and retry.

Switching to an explicit is not None comparison changes one case:
match_glob="" is now rejected on a google provider older than 10.3.0,
where truthiness previously read the supplied empty string as absent.
An empty glob is not a valid pattern and was never honoured on those
versions.

Narrow the raised exception from AirflowException to ValueError, which
is what an invalid argument warrants, and drop the file from
generated/known_airflow_exceptions.txt accordingly. This follows the
merged apache#70359 precedent for S3DeleteObjectsOperator, which made the
same one-for-one change to the same four kinds of file.

Also remove the class from the prek exemption list, since the hook
fails on stale entries, and add tests covering supplied, empty-string
and omitted match_glob.

Related: apache#70296
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