Scrub non-UTF characters from context chunk

What does this MR do and why?

Scrub non-UTF characters from context chunk

This MR removes non-UTF characters from the logged context chunks. This is because the context chunk is passed to Gitlab::Json.dump, which raises an exception if it receives a non-printable character:

Gitlab::Json.dump(chunk: "hello\x8d")

EncodingError: Invalid Unicode [8d] at 5

Gitlab::Json.dump(chunk: "hello\x8d".scrub)

"{"chunk":"hello�"}"

Changelog: fixed

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by James Nutt

Merge request reports

Loading