Skip to content

RecordRevalidator does not pass import_params to target #3

@SerylLns

Description

@SerylLns

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

  1. 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
  2. Upload a file, map columns, preview
  3. Click a cell to inline edit → save
  4. 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") || {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions