Skip to content

Commit 9074abc

Browse files
markstoryandrewshie-sentry
authored andcommitted
fix(taskworker) Remove bytes from relocation celery task (#90861)
bytes can't always be json encoded
1 parent 03d279b commit 9074abc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/sentry/relocation/services/relocation_export/impl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# in modules such as this one where hybrid cloud data models or service classes are
44
# defined, because we want to reflect on type annotations and avoid forward references.
55

6+
import base64
67
import logging
78
from datetime import UTC, datetime
89
from io import BytesIO
@@ -65,7 +66,7 @@ def request_new_export(
6566
requesting_region_name,
6667
replying_region_name,
6768
org_slug,
68-
encrypt_with_public_key,
69+
base64.b64encode(encrypt_with_public_key).decode("utf8"),
6970
int(round(datetime.now(tz=UTC).timestamp())),
7071
]
7172
)

src/sentry/relocation/tasks/process.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import base64
34
import logging
45
import re
56
from collections import defaultdict
@@ -344,7 +345,7 @@ def fulfill_cross_region_export_request(
344345
requesting_region_name: str,
345346
replying_region_name: str,
346347
org_slug: str,
347-
encrypt_with_public_key: bytes,
348+
encrypt_with_public_key: str,
348349
# Unix timestamp, in seconds.
349350
scheduled_at: int,
350351
) -> None:
@@ -357,14 +358,15 @@ def fulfill_cross_region_export_request(
357358
call is received with the encrypted export in tow, it will trigger the next step in the
358359
`SAAS_TO_SAAS` relocation's pipeline, namely `uploading_complete`.
359360
"""
361+
encrypt_with_public_key_bytes = base64.b64decode(encrypt_with_public_key.encode("utf8"))
360362

361363
logger_data = {
362364
"uuid": uuid_str,
363365
"task": "fulfill_cross_region_export_request",
364366
"requesting_region_name": requesting_region_name,
365367
"replying_region_name": replying_region_name,
366368
"org_slug": org_slug,
367-
"encrypted_public_key_size": len(encrypt_with_public_key),
369+
"encrypted_public_key_size": len(encrypt_with_public_key_bytes),
368370
"scheduled_at": scheduled_at,
369371
}
370372
logger.info(
@@ -396,7 +398,7 @@ def fulfill_cross_region_export_request(
396398

397399
export_in_organization_scope(
398400
fp,
399-
encryptor=LocalFileEncryptor(BytesIO(encrypt_with_public_key)),
401+
encryptor=LocalFileEncryptor(BytesIO(encrypt_with_public_key_bytes)),
400402
org_filter={org_slug},
401403
printer=LoggingPrinter(uuid_str),
402404
checkpointer=StorageBackedCheckpointExporter(

0 commit comments

Comments
 (0)