Skip to content

Fix CSV array output for independent sequence elements - #5978

Merged
knolleary merged 1 commit into
node-red:mainfrom
Anthounn:fix/4776-csv-independent-sequences
Oct 14, 2026
Merged

knolleary merged 1 commit into
node-red:mainfrom
Anthounn:fix/4776-csv-independent-sequences

Conversation

@Anthounn

@Anthounn Anthounn commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

Fixes #4776.

When configured to output an array, the CSV node treats any msg.parts as split CSV rows. An array/object sequence can instead contain separate complete CSV files. A single-row file is then held until the parent sequence finishes, or is emitted with an empty payload in legacy mode when it ends with a newline.

  • In both legacy and RFC4180 modes, parse array/object sequence elements independently when outputting arrays, preserving their parent parts metadata.
  • Keep string/buffer sequences and untyped parts using the existing CSV-row aggregation behavior.
  • In legacy mode, accumulate the parsed row array rather than only the final partial row object, so newline-terminated CSV parts are not lost.
  • Leave the existing single-object output mode's sequence handling unchanged.
  • Add 18 regressions covering both modes: independent array/object elements, trailing newline, single-item parent arrays, per-file headers/skipped lines, and newline-terminated string/buffer/untyped sequences.

Validation

Windows, Node.js v22.23.3:

  • Baseline CSV tests plus source/test-file check: 127 passing.
  • Before the fix, the initial 16 new tests produced 14 failures (missing output, empty payload, or removed parent metadata).
  • After the fix: 145 passing with node node_modules/mocha/bin/mocha.js test/unit/_spec.js test/nodes/core/parsers/70-CSV_spec.js test/nodes/core/parsers/70-CSV-leading-empty_spec.js --reporter dot.
  • Parser suite: 206 passing on retry. The first run had two HTML-node timeouts; the standalone HTML suite passed 17 tests and the combined parser retry passed.
  • npm test: build, dependency verification, and lint completed successfully, but the coverage/test phase exceeded the local 240-second command limit while running HTTP Request tests. The full suite is not claimed as passing.
  • git diff --check: passes.

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team (not applicable)
  • I have run npm run test to verify the unit tests pass (attempted; full run timed out as described above)
  • I have added suitable unit tests to cover the new/changed functionality

Distinguish array/object sequence metadata from split CSV rows, preserve parent parts for complete payloads, and retain newline-terminated legacy rows during aggregation.

Generated-by: OpenCode / OpenAI GPT-6.1 Sol
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Anthounn / name: Anthounn (8f16b2c)

@knolleary
knolleary merged commit 4b127e1 into node-red:main Oct 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSV Node with single-lined csv does not correctly handle 'parts' property in message object

2 participants