You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(backup): Fix various small import and comparison bugs (#60593)
For this PR, we fix the following:
1. No longer crash when comparing `None` with a nonexistent field.
Previously, this behavior was correct when comparing either of a `None`
or missing field to itself, or a present field, but not when comparing
with one another.
2. Remove existence check for `IgnoredComparator`. This makes no sense:
if we are ignoring the field for comparison purposes, we should not
raise findings when one side is missing.
3. Ignore country and/or region code re-assignments. Since we are
accepting whatever codes are assigned by the geo IP handler on the
receiving side, we should not raise alerts if this modules comes to a
different result than the exporter. Instead, we should quietly accept
the new value, and ignore the fields during comparison.
4. Allow null `expires_at` and `refresh_token` for the `ApiToken` model.
Previously, we auto-assigned these fields. But we've since encountered
instances where these are left null on purpose, so we should not mutate
this apparently valid persisted state at import time.
5. Handle unordered list fields when comparing. This is relevant
specifically to the `scope_list` field of `ApiToken`, which seems to get
the order of members shuffled a bit.
Copy file name to clipboardExpand all lines: src/sentry/backup/comparators.py
+59-12Lines changed: 59 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,8 @@
19
19
20
20
21
21
classScrubbedData:
22
-
"""A singleton class used to indicate data has been scrubbed, without indicating what that data is. A unit type indicating "scrubbing was successful" only."""
22
+
"""A singleton class used to indicate data has been scrubbed, without indicating what that data
23
+
is. A unit type indicating "scrubbing was successful" only."""
"""Compare the basic format of `QuerySubscription` IDs, which is basically a UUID1 with a numeric prefix. Ensure that the two values are NOT equivalent."""
530
+
"""Compare the basic format of `QuerySubscription` IDs, which is basically a UUID1 with a
531
+
numeric prefix. Ensure that the two values are NOT equivalent."""
reason=f"""the left value ({lv}) of the unordered list field `{f}` was not equal to the right value ({rv})""",
584
+
)
585
+
)
586
+
returnfindings
587
+
588
+
552
589
# Note: we could also use the `uuid` Python uuid module for this, but it is finicky and accepts some
553
590
# weird syntactic variations that are not very common and may cause weird failures when they are
554
591
# rejected elsewhere.
555
592
classUUID4Comparator(RegexComparator):
556
-
"""UUIDs must be regenerated on import (otherwise they would not be unique...). This comparator ensures that they retain their validity, but are not equivalent."""
593
+
"""UUIDs must be regenerated on import (otherwise they would not be unique...). This comparator
594
+
ensures that they retain their validity, but are not equivalent."""
0 commit comments