Fix 500 error when trying to upload a non-custom-filter JSON import (#40449)

This commit is contained in:
Claire committed 2026-09-15 10:23:29 +02:00
1 parent e7cf257228
commit 59e2ef27f8
2 files changed
+8 -2

No files matched your search

+7 -2
View File
@@ -202,8 +202,10 @@ class Form::Import
end
def validate_json_data
return errors.add(:data, I18n.t('imports.errors.incompatible_type')) unless allowed_type_for_json?
return errors.add(:date, I18n.t('imports.errors.no_data')) if json_data.empty?
errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if json_data.count > ROWS_PROCESSING_LIMIT
errors.add(:data, I18n.t('imports.errors.incompatible_type')) unless allowed_type_for_json?
end
def content_type_is_json?
@@ -211,7 +213,10 @@ class Form::Import
end
def json_data
parse_json['custom_filters'].map(&:deep_symbolize_keys)
case type.to_sym
when :custom_filters
parse_json['custom_filters'].map(&:deep_symbolize_keys)
end
end
def parse_json
+1
View File
@@ -1692,6 +1692,7 @@ en:
incompatible_type: Incompatible with the selected import type
invalid_csv_file: 'Invalid CSV file. Error: %{error}'
invalid_json_file: 'Invalid JSON file. Error: %{error}'
no_data: This file does not contain any data matching the given import type
over_rows_processing_limit: contains more than %{count} rows
status_not_found_warning: Some of your filters hide specific posts that are not known by this server. These posts will not be automatically filtered if they are discovered later by the server.
too_large: File is too large