SakshamSinghal20 opened a new pull request, #62258:
URL: https://github.com/apache/airflow/pull/62258
## Description
<!-- Brief description of the changes made -->
Fixes #62201: structlog configuration fails with dict input
When a dictionary is passed as a positional argument to a logging message
(e.g., `logging.getLogger(__name__).warning('Info message %s', {'a': 10})`),
Airflow's structlog processor incorrectly treats the dict as structured
context
instead of a value for string interpolation, causing a crash.
This fix modifies the structlog processor to convert dict arguments to their
string representation before processing, ensuring backward compatibility
with
existing structured logging functionality.
## Changes Made
- Modified structlog processor in `airflow/utils/log/` to handle dict
arguments
- Added type conversion for positional arguments containing dictionaries
- Ensured backward compatibility with existing structured logging (kwargs)
## Testing
- Verified fix with reproduction script:
`logging.getLogger(__name__).warning('Info message %s', {'a': 10})`
- Tested with nested dictionaries, empty dictionaries, and various data types
- Confirmed no regression in existing logging functionality
## Related Issues
- closes: #62201
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (used for understanding the issue and analyzing the logic)
<!--
Used to understand the root cause analysis and logic flow behind the
structlog
processor issue. The actual code implementation and testing was performed
manually.
-->
--
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]