FTS18 opened a new pull request, #66230:
URL: https://github.com/apache/airflow/pull/66230

   This PR fixes a critical crash in the scheduler (and other components) where 
`PercentFormatRender` would raise a `TypeError` when a numeric log format 
specifier (like `%d`) was used for callsite parameters (`process`, `thread`, 
`lineno`) that were missing or unknown.
   
   ### Problem
   As reported in #66195, during startup, certain warnings (like insecure key 
length) are emitted before the full logging context or `CallsiteParameterAdder` 
has had a chance to populate the event dictionary. In these cases, our internal 
`_LazyLogRecordDict` would return `None` or the string `"(unknown)"`. If the 
configured `log_format` uses `%d` for these fields, Python's string 
interpolation fails:
   `TypeError: %d format: a real number is required, not str`
   
   ### Solution
   Updated `_LazyLogRecordDict.__getitem__` in 
`shared/logging/src/airflow_shared/logging/percent_formatter.py` to explicitly 
handle `lineno`, `thread`, and `process`. It now returns `0` if the value is 
missing or equal to the `"(unknown)"` placeholder string.
   
   ### Changes
   - **Fix**: Logic added to `percent_formatter.py` to provide safe numeric 
defaults.
   - **Test**: Added `shared/logging/tests/logging/test_issue_66195.py` as a 
regression test.
   - **Newsfragment**: Added bugfix newsfragment.
   
   closes: #66195 


-- 
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]

Reply via email to