-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: Add dif to assemble response, Add error handling #7207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,28 @@ | |
from rest_framework.response import Response | ||
|
||
from sentry.utils import json | ||
from sentry.api.serializers import serialize | ||
from sentry.api.bases.chunk import ChunkAssembleMixin | ||
from sentry.api.bases.project import ProjectEndpoint, ProjectReleasePermission | ||
from sentry.models import File, ChunkFileState | ||
from sentry.models import File, ChunkFileState, ProjectDSymFile | ||
|
||
|
||
class DifAssembleEndpoint(ChunkAssembleMixin, ProjectEndpoint): | ||
permission_classes = (ProjectReleasePermission, ) | ||
|
||
def _add_project_dsym_to_reponse(self, found_file, response): | ||
if found_file is not None: | ||
if found_file.headers.get('error', None) is not None: | ||
response['error'] = found_file.headers.get('error') | ||
|
||
dsym = ProjectDSymFile.objects.filter( | ||
file=found_file | ||
).first() | ||
if dsym is not None: | ||
response['dif'] = serialize(dsym) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should even be required if the state is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't check this here, since the original chunked file will be deleted, only the new dsym file is in the database without the |
||
|
||
return response | ||
|
||
def post(self, request, project): | ||
""" | ||
Assmble one or multiple chunks (FileBlob) into dsym files | ||
|
@@ -58,15 +72,16 @@ def post(self, request, project): | |
chunks = file_to_assemble.get('chunks', []) | ||
|
||
try: | ||
result = self._check_file_blobs(project.organization, checksum, chunks) | ||
found_file, response = self._check_file_blobs( | ||
project.organization, checksum, chunks) | ||
# This either returns a file OK because we already own all chunks | ||
# OR we return not_found with the missing chunks (or not owned) | ||
if result is not None: | ||
file_response[checksum] = result | ||
if response is not None: | ||
# We also found a file, we try to fetch project dsym to return more | ||
# information in the request | ||
file_response[checksum] = self._add_project_dsym_to_reponse( | ||
found_file, response) | ||
continue | ||
except File.MultipleObjectsReturned: | ||
return Response({'error': 'Duplicate checksum'}, | ||
status=400) | ||
except File.DoesNotExist: | ||
pass | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just a minor consistency thing, but: What if there is an
error
header but the state isOK
? In that case it is weird, that you're adding that field.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The database doesn't prevent this from happening, but there is no codepath setting
OK
anderror
. So when there is anerror
state is also anerror
.