Fix AttributeError in SubmissionCreationSerializer when data is None#2397
Open
Didayolo wants to merge 2 commits into
Open
Fix AttributeError in SubmissionCreationSerializer when data is None#2397Didayolo wants to merge 2 commits into
Didayolo wants to merge 2 commits into
Conversation
The get_filename method in SubmissionCreationSerializer crashes with 'NoneType' object has no attribute 'data_file' when a submission has data=None (e.g. if a submission is created via API before the dataset upload completes successfully). This causes a 500 Internal Server Error on the competition detail page for ALL users, not just the one who made the incomplete API call. Apply the same null-check pattern already used in SubmissionListSerializer (line 69-73 of the same file).
Fix AttributeError in SubmissionCreationSerializer when data is None
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SubmissionCreationSerializer.get_filename()(line 121) crashes withAttributeError: 'NoneType' object has no attribute 'data_file'whensubmission.dataisNone.The same file already handles this case correctly in
SubmissionListSerializer(line 69-73):But
SubmissionCreationSerializerdoes not:Impact: A single incomplete API submission causes a 500 Internal Server Error on the competition detail page for all users, not just the caller.
Original PR
Reproduction steps
The REST API submission flow uses pre-signed S3 URLs in 4 steps:
To trigger the bug: Skip steps 2-3 (S3 upload fails or is never completed) and go directly to step 4. The API happily creates a
Submissionrecord withdata_id=None. Then visit/competitions/<id>/- the page returns 500 for every user.The traceback from Django logs:
Fix
Apply the same null-check pattern from
SubmissionListSerializer:Checklist