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

Head commit for run:
91ea42a3c2a33271d4ac430bf0459bccad11ddb0 / github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
[v3-1-test] Fix structlog JSON serialization crash on non-serializable objects 
(#62656) (#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



* 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/23163380194

With regards,
GitHub Actions via GitBox


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

Reply via email to