fix(plugin-import-export): fix CSV import of arrays and richText nested inside blocks#16922
Merged
paulpopus merged 2 commits intoJun 8, 2026
Conversation
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
PatrikKozak
requested changes
Jun 8, 2026
Contributor
There was a problem hiding this comment.
normalizeRichTextInFields reaches nested fields, but not sure it can parse a richText string. The only place a string becomes an object is the import hook in getImportFieldFunctions.ts I.e:
if (typeof value === 'string') {
try {
return JSON.parse(value)
} catch {
return value
}
}
processRichTextField.ts bails on non-objects, so it never parses:
if (!value || typeof value !== 'object') {
return value
}
If the lookup misses (blocks-in-blocks, arrayLikeNames collision), the richText could stay a string and normalizeRichText wouldn't recover it I believe
PatrikKozak
approved these changes
Jun 8, 2026
paulpopus
added a commit
that referenced
this pull request
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
faqsarray field inside afaqSectionblock) were reconstructed as plain objects with numeric keys ({"0": {...}}) instead of proper arrays on importRoot causes
Bug 1 — wrong container type for array fields inside blocks
unflattenObjecthas a special-case branch for blocks fields. When the path continued past the block field name (e.g.faqContent_0_faqSection_faqs_0_question), it always createdblockObject[fieldName] = {}, never[]. Two fixes applied:[]accordinglyelse ifbranch in the general traversal to handle the case wherecurrentObjectis already an array and the current segment is a numeric index (which happens after the block-field jump)Bug 2 — import hook not firing for richText inside nested arrays
toLogicalKeystrips array index segments from flat keys to resolve import hook registrations (e.g.faqContent_0_faqSection_faqs_0_answer→faqContent_faqSection_faqs_answer). It only strips a numeric segment when the previous segment is inarrayLikeNames.collectArrayLikeNamesrecurses viafield.flattenedFieldsbut not viafield.blocks[i].flattenedFields, so array field names declared inside block definitions (likefaqs) were never added to the set. The hook lookup therefore failed and the JSON string was left unparsed.Defence-in-depth —
normalizeRichTextkey-name heuristic replacedThe post-processing fallback in
normalizeRichTextpreviously matched block properties by checking whether the runtime key name contained"richText". This never reached fields nested inside arrays inside blocks. Replaced with a schema-driven recursive walker (normalizeRichTextInFields) that handlesrichText,blocks,array,group, andtabfields at any depth.