You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "amoghrajesh (via GitHub)" <gi...@apache.org> on 2026/04/17 14:14:25 UTC
[PR] Add prek hook to ban caplog usage in test files [airflow]
amoghrajesh opened a new pull request, #65421:
URL: https://github.com/apache/airflow/pull/65421
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull request.
Write a good git commit message following this guide: http://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the documentation.
Feel free to ping (in general) for the review if you do not see reaction for a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR, please
change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
-->
- [ ] Yes (please specify the tool below)
<!--
Generated-by: [Tool Name] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
Noticed recently in https://github.com/apache/airflow/pull/65232/ that caplog was used.
Wanted to add a prek hook to now allow this as per our coding standards: https://github.com/apache/airflow/blob/main/AGENTS.md#testing-standards.
Intent is to enforce the testing standard that tests should check logic rather than log output.
I am proposing to solve this by adding a `pygrep` hook (`check-no-caplog-in-tests`) to `airflow-core`, `providers`, and `task-sdk` pre commit config. The hook matches `\bcaplog\b` in test files and fails if any new usage is introduced.
Existing usages (35 core, 89 provider, 6 task-sdk files) are unaffected — prek only runs on files changed in a given PR, so cleanup can happen incrementally.
---
* Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#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](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #65421:
URL: https://github.com/apache/airflow/pull/65421#issuecomment-5030578706
Closing in favour of: https://github.com/apache/airflow/pull/69803
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #65421:
URL: https://github.com/apache/airflow/pull/65421#issuecomment-4932721079
Finally got back to this one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "bugraoz93 (via GitHub)" <gi...@apache.org>.
bugraoz93 commented on PR #65421:
URL: https://github.com/apache/airflow/pull/65421#issuecomment-4270560422
Since we call directly pygrep maybe we need to add skip option to ci definition
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "bugraoz93 (via GitHub)" <gi...@apache.org>.
bugraoz93 commented on PR #65421:
URL: https://github.com/apache/airflow/pull/65421#issuecomment-4270541189
We should use the label for this now as it fails for all
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #65421:
URL: https://github.com/apache/airflow/pull/65421#discussion_r3556952760
##########
scripts/ci/prek/known_caplog_usage.txt:
##########
@@ -0,0 +1,116 @@
+airflow-core/tests/integration/security/test_kerberos.py::4
Review Comment:
Following the convention recently introduce that all the generated file should be located in `airflow/generated`.
https://github.com/apache/airflow/blob/dc5ddd26202f972f634a6ee9ce25f04f17669ad7/generated/known_airflow_exceptions.txt#L1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on PR #65421:
URL: https://github.com/apache/airflow/pull/65421#issuecomment-4271648586
> Cool!
>
> But probably you need to add an exclusion list for all cases still in the repo or are we (still) clean?
Oh, just see the list of static checks, seems like a call for helping hands is needed!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #65421:
URL: https://github.com/apache/airflow/pull/65421#issuecomment-4272893396
Oh haha, seems I need to do that. Let me take a stab at that
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #65421:
URL: https://github.com/apache/airflow/pull/65421#discussion_r3557775255
##########
generated/known_caplog_usage.txt:
##########
@@ -0,0 +1,116 @@
+airflow-core/tests/integration/security/test_kerberos.py::4
Review Comment:
Good call, I wasnt aware, thanks!
##########
generated/known_caplog_usage.txt:
##########
@@ -0,0 +1,116 @@
+airflow-core/tests/integration/security/test_kerberos.py::4
Review Comment:
Handled in [fixing comemnts from jason](https://github.com/apache/airflow/pull/65421/commits/7d7e53e1da04750fd3270c882cc9b59fb2629711)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #65421:
URL: https://github.com/apache/airflow/pull/65421#issuecomment-4269545062
Rebased to run with "full tests"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #65421:
URL: https://github.com/apache/airflow/pull/65421#issuecomment-4551280491
Yes, thanks @jason810496. I will get to this next week when I have some time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on PR #65421:
URL: https://github.com/apache/airflow/pull/65421#issuecomment-4268888347
Nice improvement, I agree that we should to add the prek hook to prevent more caplog usage in the first place.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add prek hook to ban caplog usage in test files [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh closed pull request #65421: Add prek hook to ban caplog usage in test files
URL: https://github.com/apache/airflow/pull/65421
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org