Resolve "ActiveRecord::StatementInvalid: PG::UntranslatableCharacter: ERROR: unsupported Unicode escape sequence"
requested to merge 345167-activerecord-statementinvalid-pg-untranslatablecharacter-error-unsupported-unicode-escape into master
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
- Setup Integrated Error Tracking
- Verify via
curl
Variables:
-
PROJECT_ID
- Id of your project where integrated Error Tracking is enabled -
SENTRY_KEY
- Token from your Sentry DSN starting withglet_....
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.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Peter Leitzen