Description
When using inline edit on a previewing import, RecordRevalidator re-validates the edited record but the target instance has no access to import_params. This causes validation failures or skipped checks for any target that depends on import_params in its validate method.
Steps to reproduce
- Create a Target with a
param (e.g. hotel_id) and use it in validate:
params do
param :hotel_id, type: :select, required: true
end
def validate(record)
hotel_id = import_params['hotel_id']
return record.add_error('Hotel is required') if hotel_id.blank?
# ...
end
- Upload a file, map columns, preview
- Click a cell to inline edit → save
RecordRevalidator calls target.validate(record) but import_params returns {} → validation fails with "Hotel is required" even though the param was set at import creation
Root cause
RecordRevalidator instantiates the target with data_import.target_class.new without passing the import params. The import_params accessor defaults to {}.
Similarly, RecordUpdater does the same at line 8:
@target = data_import.target_class.new
Expected behavior
RecordRevalidator and RecordUpdater should hydrate import_params on the target instance from data_import.config["import_params"] before calling validate.
Suggested fix
In RecordUpdater#initialize:
@target = data_import.target_class.new
@target.import_params = data_import.config&.dig("import_params") || {}
Description
When using inline edit on a previewing import,
RecordRevalidatorre-validates the edited record but the target instance has no access toimport_params. This causes validation failures or skipped checks for any target that depends onimport_paramsin itsvalidatemethod.Steps to reproduce
param(e.g.hotel_id) and use it invalidate:RecordRevalidatorcallstarget.validate(record)butimport_paramsreturns{}→ validation fails with "Hotel is required" even though the param was set at import creationRoot cause
RecordRevalidatorinstantiates the target withdata_import.target_class.newwithout passing the import params. Theimport_paramsaccessor defaults to{}.Similarly,
RecordUpdaterdoes the same at line 8:Expected behavior
RecordRevalidatorandRecordUpdatershould hydrateimport_paramson the target instance fromdata_import.config["import_params"]before callingvalidate.Suggested fix
In
RecordUpdater#initialize: