Skip to content

Resolve "ActiveRecord::StatementInvalid: PG::UntranslatableCharacter: ERROR: unsupported Unicode escape sequence"

What does this MR do and why?

This MR fixes errors like

ActiveRecord::StatementInvalid: PG::UntranslatableCharacter: ERROR: unsupported Unicode escape sequence

when Error Tracking event payloads contain nullbytes (\u0000).

It adds a new custom ActiveRecord type JsonPgSafe which extends ActiveRecord::Type::Json and scrubs null bytes from serialized value.

Please see #345167 (closed) for more details.

How to set up and validate locally

  1. Setup Integrated Error Tracking
  2. Verify via curl

Variables:

  • PROJECT_ID - Id of your project where integrated Error Tracking is enabled
  • SENTRY_KEY - Token from your Sentry DSN starting with glet_....
curl -v -H "Content-Type: application/json" --data-binary '@spec/fixtures/error_tracking/parsed_event_nullbyte.json' http://localhost:3000/api/v4/error_tracking/collector/api/PROJECT_ID/store?sentry_key=SENTRY_KEY
# => 200 was 500 before

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports

Loading