Skip to content

update_fields: [] performs full document reindex instead of no-op #992

@dimitrikochnev

Description

@dimitrikochnev

When passing an empty array to update_fields, Chewy performs a full document reindex instead of treating it as a no-op (no fields to update). This is unexpected and dangerous behavior.

Expected Behavior

update_fields: [] should mean "update zero fields" - i.e., do nothing or skip the update. An empty array is an explicit empty set.

If "update all fields" is intended, it should be triggered by update_fields: nil or by omitting the option entirely.

Actual Behavior

update_fields: [] triggers a full document replacement, overwriting all fields with current model values.

Why This Is Problematic

Consider a pipeline that updates different transient (so I don't store fields in AR, they re simple attribute accessors) field groups:

DocumentIndex.import(
  [document],  
  direct_import: true,  
  update_fields: document.class.transient_attributes(fields_group) # --> []
)
end

This is a silent data loss bug that's very hard to debug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions