rjgoyln opened a new pull request, #73827:
URL: https://github.com/apache/airflow/pull/73827
Replaces #73076, closed under the open pull request limit. Rebased, with the
recorded occurrences refreshed for the call sites fixed since.
## Summary
Exception constructors do not interpolate. `raise
AirflowException("TaskInstance %s is not found", ti.task_id)` reads like a
logger call, but `Exception.__init__` only stores its arguments, so the message
keeps its literal `%s` and the identifier it exists to carry sits beside it in
`args`. Where the exception forwards only the message to `super()`, as
google.api_core's `GoogleAPICallError` family does, that identifier is dropped
entirely.
Twenty-eight remain on main across five distributions, enough to read as
house style to anyone reviewing a new one, and they keep arriving — eight came
in with the Gemini operators in January 2026. Ruff does not reach this shape:
its logging rules only inspect logging calls, and `EM101` objects to the string
literal rather than the swallowed arguments, so taking its suggested fix leaves
the bug in place.
## Change
- Add prek hook `check-no-new-exception-format-args`, subclassing
`AllowlistManager` beside `check-no-new-airflow-exceptions`.
- Flag a raise only when the placeholder count matches the number of
trailing positional arguments, as Python's `%` operator would consume them.
- Record the 28 existing occurrences, which this PR does not fix.
The exact-count rule buys precision at the cost of recall. Several call
sites pass a literal message alongside unrelated positional parameters, such as
`TypeError("Could not parse hits.", response)`, and a looser check would flag
those too.
Counts are stored per file, so the hook blocks a net increase rather than
tracking individual occurrences — the same trade-off as the neighbouring
allowlist checks.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 5)
Generated-by: Claude Code (Opus 5) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]