mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-01 07:03:22 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user