From 1855da54e0bd0d70362ba6a439afe20a87ca1253 Mon Sep 17 00:00:00 2001 From: pyxelr Date: Thu, 28 May 2026 17:43:29 +0200 Subject: [PATCH] Fix AttributeError in SubmissionCreationSerializer when data is None 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). --- src/apps/api/serializers/submissions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/apps/api/serializers/submissions.py b/src/apps/api/serializers/submissions.py index 9c91737ca..e2436f596 100644 --- a/src/apps/api/serializers/submissions.py +++ b/src/apps/api/serializers/submissions.py @@ -118,7 +118,9 @@ class Meta: } def get_filename(self, instance): - return basename(instance.data.data_file.name) + if instance.data and instance.data.data_file: + return basename(instance.data.data_file.name) + return None def create(self, validated_data): tasks = validated_data.pop('tasks', None)