The GitHub Actions job "Tests" on airflow.git/backport-0b43077-v3-1-test has 
succeeded.
Run started by GitHub user jscheffl (triggered by jscheffl).

Head commit for run:
e134fe412c9d50f348255e4f30b217b49760b0fd / deepinsight coder 
<[email protected]>
[v3-1-test] Fix structlog JSON serialization crash on non-serializable objects 
(#62656)

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

Report URL: https://github.com/apache/airflow/actions/runs/23163212258

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to