github-actions[bot] opened a new pull request, #63721:
URL: https://github.com/apache/airflow/pull/63721

   * Fix structlog JSON serialization crash on non-serializable objects
   
   Wrap the enc_hook in json_dumps() with a safe_default() fallback that
   catches TypeError and falls back to str(). This prevents the logging
   pipeline from crashing when log event dicts contain objects that
   msgspec cannot serialize.
   
   Closes: #62472
   Closes: #62201
   
   Co-Authored-By: Claude Opus 4.6 <[email protected]>
   
   * Address review: hoist safe_default into factory, add tests
   
   - Move the inline safe_default closure out of json_dumps into a
     module-level _make_safe_enc_hook factory function to avoid
     recreating it on every JSON log line.
   - Add test for the actual crash scenario: an object whose
     __structlog__() raises TypeError now falls back to str() instead
     of crashing the logger.
   - Add regression test confirming normal custom objects still
     serialize via repr() through the standard enc_hook path.
   - Add unit test for the default=None edge case in _make_safe_enc_hook.
   
   * Handle UnicodeEncodeError in structlog JSON serialization
   
   Broaden exception handling to catch ValueError (including
   UnicodeEncodeError) in the enc_hook, and add a fallback around
   msgspec.json.encode() to replace surrogate characters that can't
   be encoded to UTF-8 JSON.
   
   ---------
   (cherry picked from commit 0b43077a26e5c8dc2447e89980152b7964965aa7)
   
   Co-authored-by: deepinsight coder 
<[email protected]>
   Co-authored-by: Claude Opus 4.6 <[email protected]>


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