YoannAbriel opened a new pull request, #62849:
URL: https://github.com/apache/airflow/pull/62849
Closes: #62201
## Summary
`log.warning('%s', {'a': 10})` crashes with `TypeError` because structlog
tries named substitution (`msg % args[0]`) before positional (`msg % args`),
opposite to CPython's stdlib logging.
## Changes
- Reversed try-order in `_AirflowBoundLogger._make_method()` to match
CPython: try positional first, fall back to named substitution on
`TypeError`/`KeyError`
- Added custom `positional_arguments_formatter` processor replacing
structlog's built-in `PositionalArgumentsFormatter` (same root cause)
- 8 parametrized tests covering: dict positional, dict named, simple
positional, no-args — for both stdlib and structlog loggers
## Context
Two other PRs exist for this issue:
- #62258 — stale, got CHANGES_REQUESTED (reviewer incorrectly claimed stdlib
crashes too — it doesn't)
- #62656 — potentially overlapping, different approach
Our fix mirrors CPython's exact logic from
`Lib/logging/__init__.py#L307-L326`.
- [X] Yes — generative AI tooling was used to co-author this PR (Claude).
--
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]