target / goalert

Open source on-call scheduling, automated escalations, and notifications so you never miss a critical alert
https://goalert.me
Apache License 2.0
2.17k stars 230 forks source link

`JSON` Column Data Altered During Switchover #3942

Open mastercactapus opened 5 days ago

mastercactapus commented 5 days ago

Describe the Bug: The data contained within json-type columns seems to get altered during a switchover operation. Specifically, the order of keys in the JSON policy column of gql_api_keys changes after performing a switchover.

Steps to Reproduce:

  1. Run GoAlert commit a25f8082e975812ff5d4b88416768cd931aaa34c or earlier (using make start-swo)
  2. Create a GraphQL API key and verify it functions
  3. Perform a switchover (Admin > Switchover)
  4. Observe that the API key no longer works

Expected Behaviour: For json-type columns, the data should be preserved exactly during switchover operations. This includes preventing change to the order of keys within the JSON documents stored within these columns.

Observed Behavior: After performing a switchover, the order of keys in the JSON data changes. This suggests that the data might be parsed into a map and then re-encoded, rather than being copied as a json.RawMessage.

Application Version: This issue affects all known versions up to and including the commit a25f8082e975812ff5d4b88416768cd931aaa34c.

Additional Context: This issue was identified due to GraphQL API keys being rejected following a switchover, as the data alteration resulted in a hash mismatch.

This issue specifically affects the backend.