|
@@ -19,7 +19,7 @@ from sentry.cache import default_cache
|
|
|
from sentry.models import Organization
|
|
|
from sentry.net.http import Session
|
|
|
from sentry.tasks.store import RetrySymbolication
|
|
|
-from sentry.utils import json, metrics
|
|
|
+from sentry.utils import json, metrics, safe
|
|
|
|
|
|
MAX_ATTEMPTS = 3
|
|
|
REQUEST_CACHE_TIMEOUT = 3600
|
|
@@ -362,7 +362,7 @@ def parse_backfill_sources(sources_json, original_sources):
|
|
|
try:
|
|
|
sources = json.loads(sources_json)
|
|
|
except Exception as e:
|
|
|
- raise InvalidSourcesError(f"{e}")
|
|
|
+ raise InvalidSourcesError("Sources are not valid serialised JSON") from e
|
|
|
|
|
|
orig_by_id = {src["id"]: src for src in original_sources}
|
|
|
|
|
@@ -377,15 +377,17 @@ def parse_backfill_sources(sources_json, original_sources):
|
|
|
|
|
|
for secret in secret_fields(source["type"]):
|
|
|
if secret in source and source[secret] == {"hidden-secret": True}:
|
|
|
- orig_source = orig_by_id.get(source["id"])
|
|
|
- # Should just omit the source entirely if it's referencing a previously stored
|
|
|
- # secret that we can't find
|
|
|
- source[secret] = orig_source.get(secret, "")
|
|
|
+ secret_value = safe.get_path(orig_by_id, source["id"], secret)
|
|
|
+ if secret_value is None:
|
|
|
+ sentry_sdk.capture_message("Hidden secret not present in project options")
|
|
|
+ raise InvalidSourcesError("Sources contain unknown hidden secret")
|
|
|
+ else:
|
|
|
+ source[secret] = secret_value
|
|
|
|
|
|
try:
|
|
|
jsonschema.validate(sources, SOURCES_SCHEMA)
|
|
|
except jsonschema.ValidationError as e:
|
|
|
- raise InvalidSourcesError(f"{e}")
|
|
|
+ raise InvalidSourcesError("Sources did not validate JSON-schema") from e
|
|
|
|
|
|
return sources
|
|
|
|