Skip to content

Normalize non-serializable values to string for JSON logger

Igor Ponomarev requested to merge collabora-skip-json-keys into collabora/staging

Otherwise logger fails to work and raises the TypeError.

Example error:

TypeError: Object of type type is not JSON serializable

Looks like certain log messages passed by lava will contain the type classes. By passing the default=str option the JSON sertializer will call str() on any non-serializable value.

Example:

>>> json.dumps({"a": str})
TypeError: Object of type type is not JSON serializable
>>> json.dumps({"a": str}, default=str)
'{"a": "<class \'str\'>"}'

Merge request reports