Invalid Unicode 500 Error when pushing an image binary with GitGuardian enabled

Overview

If a customer has GitGuardian enabled and attempts to push a commit with an image binary included the GitGuardian client has an error on params.to_json

"ua": "gitaly/17.0.4",
"route": "/api/:version/internal/allowed",
"exception.class": "JSON::GeneratorError",
"exception.message": "Invalid Unicode [a8 dc 8b 8c aa] at 0",
"exception.backtrace": [
  "lib/gitlab/json.rb:270:in `rescue in stringify'",
  "lib/gitlab/json.rb:265:in `stringify'",
  "activesupport (7.0.8.1) lib/active_support/json/encoding.rb:35:in `encode'",
  "activesupport (7.0.8.1) lib/active_support/json/encoding.rb:22:in `encode'",
  "activesupport (7.0.8.1) lib/active_support/core_ext/object/json.rb:42:in `to_json'",
  "ee/lib/gitlab/git_guardian/client.rb:76:in `perform_request'",
  "ee/lib/gitlab/git_guardian/client.rb:55:in `block in execute_batched_request'"
]
"exception.cause_class": "EncodingError",

This happens here: https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/gitlab/git_guardian/client.rb?ref_type=heads#L76

Possible fixes

The only success we've seen is turning off GitGuardian completely.

Edited by Michael Lussier