Skip to content

[plugin-import-export] Empty array columns stay in the CSV header when a field beforeExport hook returns one value #19141

Open

Description

@tiendungnguyen24

Describe the Bug

A field-level hooks.beforeExport on an array field returns one string, so the CSV gets one column for that field (tags). The CSV header still has the schema columns of the array (tags_0_label, tags_0_id), and they are always empty.

Link to the code that reproduces this issue

https://github.com/tiendungnguyen24/payload-import-export-csv-repro

Reproduction Steps

  1. Clone the repository, pnpm install, cp .env.example .env.
  2. pnpm payload run src/seed.ts.
  3. pnpm dev.
  4. ./repro.sh.
  5. The header is id,title,items_0_label,items_0_id,tags_0_label,tags_0_id,updatedAt,tags,createdAt. tags has the hook value (x | y), and tags_0_label and tags_0_id are empty in every row.

The field config is in src/collections/Posts.ts.

Which area(s) are affected?

plugin: import-export

Environment Info

payload: 3.92.1
@payloadcms/plugin-import-export: 3.92.1
@payloadcms/db-sqlite: 3.92.1
next: 16.3.3
Node: 26.5.1
pnpm: 11.23.0
OS: macOS (darwin arm64)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions