Repository navigation
JSE-58: maxCellTextLength limit, message excerpts of long text, maxIssues for importDataset - #132
Merged
Merged
Conversation
…maxIssues for importDataset - New optional ReadLimits.maxCellTextLength (default 1,048,576): one cell's text (shared string, inline string, <v>, formula), counted after decoding while it streams in. Also a CSV option, and importDataset passes limits.maxCellTextLength to the CSV parser. - Warning, issue and error messages quote text over 128 characters as a 64-character excerpt plus its length; fields are unchanged. - importDataset: maxIssues (default 100,000) bounds the issue list while it is built; dropped issues are counted in meta.droppedIssues, and the first issue of each code is always kept. - maxXmlTokenLength documentation says it does not limit text.
…r, docs - maxCellTextLength also bounds header/footer text, defined-name formulas and document property values, counted as written while they stream in. - The overlap error quotes an excerpt of long entry names. - importDataset keeps CSV's 1 MiB maxFieldBytes unless maxCellTextLength asks for more characters than 1 MiB can hold. - An abort raised before the types and mapping are decided wins over a bad option again, as in 2.2.0. - maxIssues accepts Infinity (no cap). - Tests pin the CSV check order, raw counting of number <v> text and the 500,000-issue case that overflowed the call stack in 2.2.0. - Docs and changeset state what is bounded and what is not, which limit covers which text, details.value per limit, and server guidance.
This was referenced Dec 1, 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.
Gap
importDataset's TYPE issue was built as${ref}: ${JSON.stringify(String(value))} is not a ${type}., so one long shared string used by many cells made one full copy per message.maxXmlTokenLengthlimits tags, not the text between them, though its documentation read as if it capped cell values: a 16,000,000-character shared string read withmaxXmlTokenLengthat 64 KiB.Measurements (Node 26, Apple-silicon laptop,
--max-old-space-size=4096)types: { date: 'date' }LimitError,details: { limit: 'maxCellTextLength', value: 1048577, max: 1048576, part: 'xl/sharedStrings.xml' }maxCellTextLength: 16_000_000: 10,000 issues in 0.2 s, 1,108,898 characters of messages, longest 112, 85 MB heapMessage after:
A2: "iiiosmmqqoaskgeeqqsaayieoswwuicoiscoqagigqoksuwueamisgicmkwcsimc"… (16000000 characters) is not a date.What changes
ReadLimits.maxCellTextLength(optional member, default 1,048,576 characters, inDEFAULT_READ_LIMITS). One cell's text as the cell will hold it: a shared string (<si>) or inline string (<is>), rich-text runs together and phonetic runs left out, and the text of a<v>and of an<f>. Counted in UTF-16 code units after entities and_xHHHH_escapes are decoded, while the text streams in (a streaming counter holds back at most 6 characters that may start an escape), so a longer text is refused before it is held whole. Fails as the other limits do:LimitError,LIMIT_EXCEEDED,details: { limit: 'maxCellTextLength', value: max + 1, max, part, ref? }(reffor sheet cells).Default on, at 1 Mi:
maxFieldBytes(1 MiB), so with both defaults the CSV parser behaves exactly as before (a field over 1 Mi characters has at least that many bytes, andmaxFieldBytesis still checked first).Where the option goes:
read, the worker client'sread:limits.maxCellTextLength.parseCsv/readCsv, the worker client'sparseCsv: new CSV optionmaxCellTextLength, alongsidemaxFieldBytes(both apply).importDataset(and its worker call):limits.maxCellTextLengthfor xlsx and CSV. For CSV it is passed through; CSV'smaxFieldBytesstays at 1 MiB unlessmaxCellTextLengthis above 1,048,576 (more characters than 1 MiB can hold), and then becomes3 × maxCellTextLength. A byte cap is never loosened otherwise (spreadingDEFAULT_READ_LIMITSkeeps 1 MiB).readSheetNamesapplies it to defined-name formulas.Excerpts in messages. Text over 128 characters is quoted as its first 64 characters,
…and its length; text up to 128 characters is quoted as before, so ordinary messages are unchanged. Codes and fields (ref,sheet,part,column,details) are never shortened. Changed builders:importDatasetissues:TYPE(also from the publiccoerceColumns),DATE_ORDER_AMBIGUOUS(column key),ERROR_CELL(error text).INVALID_CELL_REF,CELL_OUT_OF_BOUNDS,INVALID_SHARED_STRING(the<v>text),ROWS_TRUNCATED(sheet name),MISSING_PART(target, sheet name),BROKEN_OPTIONAL_PART(part),HYPERLINK_RANGE_REDUCED(range).XML_MALFORMEDmessages, the part-name prefixwithPartadds, zip entry names (ZIP_ENCRYPTED,ZIP_UNSUPPORTED_METHOD,ZIP_INVALID,ZIP_CRC_MISMATCH,maxEntryBytes), and OPC case-clash part names.importDatasetmaxIssues(default 100,000, an integer of at least 1). No limit existed. The list is now bounded while it is built, not filtered afterwards: untilmaxIssuesissues are kept every issue is kept, in the 2.2 order; past it an issue is kept only if it is the first of its code, and the others are counted inmeta.droppedIssues: { total, byCode }(present only when something was dropped). Each code has one severity, so a list cut short still holds anerrorwhenever one was dropped. The same idea as the warning cap from JSE-46, reported inmetarather than as a new issue code so thatImportIssueCodedoes not widen. To bound the list while it is built, the pipeline now decides the mapping before converting values and drops issues on unmapped columns as they occur; the TYPE-then-REQUIRED suppression uses a per-column bitmap of failed rows instead of a set of every TYPE issue.Docs.
maxXmlTokenLength(JSDoc and docs/api.md §5.2) now says it does not limit text and points tomaxCellTextLength; new limit row in §5.2, CSV option in §5.3,maxIssuesanddroppedIssuesand the excerpt rule in §5.6, the excerpt rule in §7.3, a "Huge cell text" row in §8, README limits line.Compatibility. Additive: new optional members and options; for files within the new limit, results, warnings and errors are unchanged except the intended message shortening (fuzz below). A complete 2.2-style
ReadLimitsliteral still compiles (consumer-ts fixture added). Changeset: minor (new options plus a safety fix, as formaxSheets/maxItemsin #130).Tests
Written first and run red against the unchanged source (CSV option ignored, the 16 M file not refused, the 10,000-row import test crashed the vitest worker with SIGABRT), then green.
test/read/cell-text-limit.test.ts: the default; a 32,767-character cell reads with defaults; the 16,000,000-character file (built in the test, under 400 KB) is refused withpart, reads with onlymaxXmlTokenLengthlowered to 64 Ki whenmaxCellTextLengthis raised, and is refused on the deferred (maxRows) path; at/over the limit (10 reads at 10, refused at 9) for shared string, two<t>, shared rich text, inline string, inline rich text,t="str"<v>, number<v>, formula, entities,_xHHHH_escapes;details.ref; phonetic runs and never-decoded strings do not count; validation throughreadandreadSheetNames;StringItemthrows at the chunk that passes the limit; the streaming counter equalsdecodeXstring(s).lengthfor every split of 2,000 seeded random strings (over 10,000 splits); excerpt rules; long file text inINVALID_CELL_REF,INVALID_SHARED_STRING,ROWS_TRUNCATED,HYPERLINK_RANGE_REDUCED,MISSING_PARTand an XML error stays under 400 characters with full fields.test/csv/cell-text-limit.test.ts: defaults unchanged; at/over the limit withdetails.value,ref; unquoted length; both limits apply;readCsv; validation.test/import/issue-bounds.test.ts: the 16 M file refused by default; with the limit raised, 10,000 rows give 10,000 issues of at most 120 characters; 60,000 characters in 20 columns × 1,000 rows give 20,000 issues of at most 120 characters; the same in CSV; short messages unchanged;coerceColumns;DATE_ORDER_AMBIGUOUS;maxIssuesdefault, cap, first-of-each-code, dropped columns never count, REQUIRED still suppressed after a dropped TYPE issue, validation;limits.maxCellTextLengthreaches CSV and raising it lets a 1.5 M field through.test/worker/worker.test.ts:maxCellTextLengththroughread,parseCsvandimportDataset, andmaxIssues/droppedIssuesacross the boundary.Local:
npm run typecheck,npm test(1,182 passed; the one failure,test/format/libreoffice.test.ts, fails identically on main with the local LibreOffice and is not part of the required job),npm run build,npm run lint,npm run smoke,npm run consumer-ts(TypeScript 5.0 to 7.0), dependency guard,npm run docs:check.Differential fuzz against 2.2.0
A seeded generator of workbooks (shared strings with runs, phonetic runs,
_xHHHH_and entity text; inline strings;str,n,b,e,dcells with valid and invalid values; invalid, out-of-bounds and long references; long sheet names; hyperlink ranges; a missing shared-strings target; occasional malformed XML) and CSV text (quotes, doubled quotes, mixed delimiters, long fields), run throughread(randomrichText,maxRows,rawText),importDataseton the xlsx (randomtypes,header, schema with required and typed fields),parseCsv(randominferTypes, strict mode,maxRows) andimportDataseton the CSV (randomtypes,locale.dateOrder), against the published 2.2.0 tarball. Results and errors must be deep-equal; a message may differ only by being shorter and carrying the excerpt marker.The first trial run found that a 65 to 80 character value got a longer "excerpt" than itself; quoting text in full up to 128 characters fixed that before these runs.
Performance
bench/run.mjsA/B against 2.2.0 at 1M cells (two interleaved rounds):readplain 560/575 ms vs 699/548 ms, unique 1,089/1,164 ms vs 1,148/1,152 ms;csv-readplain 58/60 vs 65/63 ms, unique 81/74 vs 99/80 ms. Within noise; heap unchanged.Review fixes (second commit)
maxCellTextLengthalso bounds header/footer text, defined-name formulas and core, extended and custom document property values, counted as written while they stream in (details.partnames the part). Before, a 1.67 MB file gave a 100,000,000-character<oddHeader>.<v>, formulasmaxCellTextLengthmaxCellTextLengthTarget), locations, tooltips, display text, number format codes,sqrefmaxXmlTokenLength(whole tag)UNSUPPORTED_PART)importDatasetand the CSV byte cap: see "Where the option goes" above.onProgressat "dataset" wins over a badtypes/mappingoption again, as in 2.2.0.maxIssues: Infinitymeans no cap.RangeError: Maximum call stack size exceeded; this branch keeps 100,000 and counts 400,000 (pinned by a test).maxFieldBytes; this fails if the checks are swapped.<v>of_x0041__x0042_counts 14 characters; this fails if it is decoded.details.valueper limit in one place.