Repository navigation
Conversation
Excel's "CSV UTF-8" export starts with a BOM, and CSVToList decoded a BytesIO with plain
utf-8 and handed the resulting U+FEFF to the parser. With a header row the first column's
key came out as "\ufeffname", so a lookup by the header the user sees ("name") missed it,
and in an agent flow the dirty key reached the model as a field name; without a header
the first cell kept the marker in its value.
A BytesIO now decodes as utf-8-sig, which drops the BOM and leaves data without one
untouched, and a string that already carries the decoded marker has it removed before
parsing. CSVConverter and the Excel converter already read CSV through utf-8-sig (nodes/
converters/csv.py, components/converters/excel.py), so the transformer now agrees with
them on the same file.
No charset guessing is added: charset_normalizer reads a short GBK sample as euc-kr and
returns Korean mojibake, which is worse than the decode error this reports today.
xdAsaah
force-pushed
the
fix/csv-to-list-bom
branch
from
November 28, 2026 09:48
58d9d76 to
0d7bb8f
Compare
This branch has not been deployed
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.
Problem
CSVToListdecodes aBytesIOwith plainutf-8and passes the text tocsv.DictReader. Excel's "CSV UTF-8" export — the usual export when the data holds non-ASCII text — starts with a UTF-8 BOM, which survives the decode as U+FEFF, so the first column is polluted:is_header_exists=True, the default) the first row's key comes out as"\ufeffname"instead of"name". Reading it by the header the user sees fails, and in an agent flow the dirty key is handed to the model as a field name;"\ufeffname").The project already reads CSV through
utf-8-sig:CSVConverteropens paths andBytesIOwithencoding="utf-8-sig"(dynamiq/nodes/converters/csv.py:148,:177) and the Excel converter reads CSV the same way (dynamiq/components/converters/excel.py:249,:296). The transformer is the one place that does not, so the two CSV entry points disagree on the same file.Compatibility
Data without a BOM decodes exactly as before —
utf-8-sigis plainutf-8when no BOM is present — and the string input path only loses a leading U+FEFF. No signature, output shape or error behavior changes otherwise.No charset guessing is added on purpose:
charset_normalizerreads a short GBK sample as euc-kr and returns Korean mojibake, which would be worse than the decode error it reports today.Verified
Before the change (its parent) and after, with the repo's test dependencies installed:
tests/unit/nodes/transformers/test_csv_to_list_bom.py(new, 4 cases): 3 failed → 4 passedBytesIO+ BOM + header:{"\ufeffname": "Alice", "age": "30"}→{"name": "Alice", "age": "30"}str+ BOM + header: sameBytesIO+ BOM,is_header_exists=False:{"column0": "\ufeffname"}→{"column0": "name"}BytesIOwithout BOM: unchangedtests/integration/nodes/transformers/test_csv_excel_transformers.py: 6 passed, unchangedBytesIOwith plainutf-8reddens both BOM byte cases; dropping theremoveprefixreddens the string case — each half is guarded on its ownflake8 --max-line-length=120andisort --profile blackclean on both filesThis change was prepared with AI assistance.