Skip to content

build(prek-hook): Check whether new "raise AirflowException" is added#55416

Merged
jscheffl merged 6 commits intoapache:mainfrom
astronomer:script-to-check-new-airflow-except
Apr 9, 2026
Merged

build(prek-hook): Check whether new "raise AirflowException" is added#55416
jscheffl merged 6 commits intoapache:mainfrom
astronomer:script-to-check-new-airflow-except

Conversation

@Lee-W
Copy link
Copy Markdown
Member

@Lee-W Lee-W commented Sep 9, 2025

Why

https://lists.apache.org/thread/t8bnhyqy77kq4fk7fj3fmjd5wo9kv6w0

What

Add prek hook to detect raise AirflowException


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch from f67ff02 to 23f571c Compare September 13, 2025 06:45
@Lee-W Lee-W marked this pull request as ready for review September 13, 2025 06:52
Copy link
Copy Markdown
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

The currect check strategy implies that if I fix an AirflowException-typo that I am not allowed to.I asusme this is for the moment acceptable... just am thinking about this. But have no other good strategy idea in mind.

@Lee-W
Copy link
Copy Markdown
Member Author

Lee-W commented Sep 14, 2025

The currect check strategy implies that if I fix an AirflowException-typo that I am not allowed to.I asusme this is for the moment acceptable... just am thinking about this. But have no other good strategy idea in mind.

Yep, we probably could exclude that file if needed. But this is the best I can think of now.

@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch 3 times, most recently from 506f630 to 9cd9e6d Compare September 22, 2025 08:04
@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch from 9cd9e6d to 30615ae Compare September 28, 2025 02:59
@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch 4 times, most recently from 288a6a3 to 73f587c Compare October 13, 2025 02:03
@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch 2 times, most recently from aaab427 to 621e7bc Compare October 13, 2025 13:02
@potiuk
Copy link
Copy Markdown
Member

potiuk commented Oct 13, 2025

The currect check strategy implies that if I fix an AirflowException-typo that I am not allowed to.I asusme this is for the moment acceptable... just am thinking about this. But have no other good strategy idea in mind.

Maybe better solution:

  • dump (automatically) list of used Exceptions to a .txt file
  • fail if a found exception is not on the list
  • add a flag to the script to clean-up removed exceptions when --all-files are used
  • prek run check_no_new_airflow_exceptions_added (default - fails if not on list)
  • prek run check_no_new_airflow_exceptions_added --all-files (check all)
  • uv run ./scripts/ci/prek/check_no_new_airflow_exceptions_added.py --cleanup - removes all exceptions from .txt file when already removed in the code

Or similar.

@Lee-W Lee-W marked this pull request as draft October 15, 2025 10:10
@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch from 621e7bc to b109e01 Compare October 22, 2025 08:41
@github-actions
Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@Lee-W
Copy link
Copy Markdown
Member Author

Lee-W commented Feb 15, 2026

@Lee-W would it be ok if I take over of the implementation? I just reviewed a PR where I almost missed new usage of AirflowException, and I want to promote an action to prevent it for the next times. Thank you!

That would be awesome! I really want to go back and get this one done, but never actaully have the bandwidth to do so.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Apr 4, 2026
@Lee-W Lee-W removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Apr 4, 2026
@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch from b109e01 to 5c26c0b Compare April 7, 2026 07:53
@Lee-W Lee-W marked this pull request as ready for review April 7, 2026 08:05
@Lee-W
Copy link
Copy Markdown
Member Author

Lee-W commented Apr 7, 2026

@potiuk @shahar1 I tried to wrap up this PR created long long long ago (with Claude). Please take a look when you have some time :)

Copy link
Copy Markdown
Contributor

@shahar1 shahar1 left a comment

Choose a reason for hiding this comment

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

Thanks for creating it, and apologies that I couldn't finish it up on my own.
Few comments :)

@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch from 5c26c0b to c3b6c00 Compare April 7, 2026 09:16
@Lee-W Lee-W requested a review from shahar1 April 7, 2026 11:30
@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch from 9ebcfb6 to 99ada8e Compare April 9, 2026 03:27
@Lee-W Lee-W force-pushed the script-to-check-new-airflow-except branch from 99ada8e to 4724c32 Compare April 9, 2026 09:33
@potiuk
Copy link
Copy Markdown
Member

potiuk commented Apr 9, 2026

Oh wow. We have that many ?

Copy link
Copy Markdown
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

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

Nice! I like this simple and smart way to keep track of all existing overly broad ‎AirflowException usages. It should help avoid adding too many broad ‎AirflowException usages and will serve as a final warning for contributors.

Copy link
Copy Markdown
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

Oh, wow, really many. Let me fix the edge3 provider one :-D

@jscheffl jscheffl merged commit 6f56aa1 into apache:main Apr 9, 2026
142 checks passed
Lee-W added a commit to astronomer/airflow that referenced this pull request Apr 10, 2026
…apache#55416)

* build(prek-hook): Check whether new "raise AirflowException" is added

* feat: add white list

* refactor: simplify the record to use count instead of raw content

* fixup! refactor: simplify the record to use count instead of raw content

* refactor: filter python files that matters

* fixup! refactor: filter python files that matters

(cherry picked from commit 6f56aa1)
Lee-W added a commit to astronomer/airflow that referenced this pull request Apr 10, 2026
…apache#55416)

* build(prek-hook): Check whether new "raise AirflowException" is added

* feat: add white list

* refactor: simplify the record to use count instead of raw content

* fixup! refactor: simplify the record to use count instead of raw content

* refactor: filter python files that matters

* fixup! refactor: filter python files that matters
Lee-W added a commit to astronomer/airflow that referenced this pull request Apr 10, 2026
Lee-W added a commit that referenced this pull request Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants