Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/sentry/api/endpoints/project_symbol_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from sentry.lang.native.sources import (
REDACTED_SOURCE_SCHEMA,
REDACTED_SOURCES_SCHEMA,
SOURCES_WITHOUT_APPSTORE_CONNECT,
VALID_CASINGS,
VALID_LAYOUTS,
InvalidSourcesError,
Expand Down Expand Up @@ -337,7 +338,8 @@ def post(self, request: Request, project: Project) -> Response:
sources.append(source)

try:
validate_sources(sources)
# TODO(@anonrig): Update this schema when AppStore connect is sunset.
validate_sources(sources, schema=SOURCES_WITHOUT_APPSTORE_CONNECT)
except InvalidSourcesError:
return Response(status=400)

Expand Down
17 changes: 15 additions & 2 deletions src/sentry/lang/native/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@
"items": SOURCE_SCHEMA,
}

# TODO(@anonrig): Remove this when AppStore connect integration is sunset.
# Ref: https://github.com/getsentry/sentry/issues/51994
SOURCES_WITHOUT_APPSTORE_CONNECT = {
"type": "array",
"items": {
"oneOf": [
HTTP_SOURCE_SCHEMA,
S3_SOURCE_SCHEMA,
GCS_SOURCE_SCHEMA,
]
},
}


# Schemas for sources with redacted secrets
HIDDEN_SECRET_SCHEMA = {
Expand Down Expand Up @@ -355,13 +368,13 @@ def secret_fields(source_type):
yield from []


def validate_sources(sources):
def validate_sources(sources, schema=SOURCES_SCHEMA):
"""
Validates sources against the JSON schema and checks that
their IDs are ok.
"""
try:
jsonschema.validate(sources, SOURCES_SCHEMA)
jsonschema.validate(sources, schema)
except jsonschema.ValidationError as e:
raise InvalidSourcesError(f"{e}")

Expand Down