Require data_file when data_source is specified

data_source alone is not a valid creation payload — a data_file must
also be provided to identify which file within the source to sync.
Add the corresponding validation error and a test to cover the case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Arthur
2026-03-30 15:36:51 -07:00
parent 3bd2dbea86
commit f9af8e2068
2 changed files with 17 additions and 2 deletions

View File

@@ -57,9 +57,13 @@ class ScriptModuleSerializer(ValidatedModelSerializer):
raise serializers.ValidationError(
_("Cannot upload a file and sync from a data source.")
)
if self.instance is None and not upload_file and not has_data_file and not has_data_source:
if has_data_source and not has_data_file:
raise serializers.ValidationError(
_("Must upload a file or provide a data source or data file to sync.")
_("A data file must be specified when syncing from a data source.")
)
if self.instance is None and not upload_file and not has_data_file:
raise serializers.ValidationError(
_("Must upload a file or provide a data source and data file to sync.")
)
return data