[Bug]: Array formula spill cells serialize as literal values, so rebuildAndRecalculate() produces #SPILL!
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- backend
Hướng nghiên cứu
Bắt đầu trong src/Serialization.ts, đặc biệt là getCellSerialized() và getCellFormula(), sau đó chạy bản tái hiện Node độc lập từ issue. Xác minh rằng các ô spill của mảng không phải ô neo được serialize mà không có các giá trị đã tính toán, đồng thời getSheetSerialized() và rebuildAndRecalculate() giữ nguyên kết quả của công thức mảng mà không tạo ra #SPILL!.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
A cell holding an array formula such as ={1,2} calculates correctly and spills across A1 and B1. Calling rebuildAndRecalculate() turns it into #SPILL!.
The cause is in serialization, not in the rebuild itself.
rebuildAndRecalculate() does not rebuild from the stored formulas. It serializes every sheet, then builds a new engine from that serialized content:
// src/HyperFormula.ts — rebuildWithConfig()
const serializedSheets = this._serialization.withNewConfig(configNewLanguage, this._namedExpressions).getAllSheetsSerialized()
The serializer then writes out the computed spill value for B1 as if it were cell content:
// src/Serialization.ts:64
public getCellSerialized(address: SimpleCellAddress, targetAddress?: SimpleCellAddress): RawCellContent {
return this.getCellFormula(address, targetAddress) ?? this.getRawValue(address)
}
getCellFormula() deliberately returns undefined for a cell that belongs to an array but is not that array's anchor cell (src/Serialization.ts:48-52). The ?? then falls through to getRawValue(), which returns the spilled value.
For B1 in the example above:
| call | result |
|---|---|
isCellPartOfArray(B1) |
true |
getCellFormula(B1) |
undefined |
getCellSerialized(B1) |
2 |
So the sheet serializes to [["={1,2}", 2]]. B1 now holds a hard-coded 2. The new engine builds from that, ={1,2} has no room to spill into B1, and A1 becomes #SPILL!.
The serialize-then-rebuild round trip is not idempotent for array formulas. The spilled value is baked in as real content, and then blocks its own formula.
Steps to reproduce
import { HyperFormula } from 'hyperformula';
const hf = HyperFormula.buildFromArray([['={1,2}', null]], { licenseKey: 'gpl-v3' });
console.log(hf.getSheetValues(0)); // [[1, 2]] correct
console.log(hf.getSheetSerialized(0)); // [["={1,2}", 2]] already wrong
hf.rebuildAndRecalculate();
console.log(hf.getSheetValues(0)); // [[#SPILL!, 2]] bug
Expected behavior
rebuildAndRecalculate() preserves the array formula result: [[1, 2]].
A cell that is part of an array but is not the array's anchor has no content of its own, so it should serialize to nothing.
Notes
This is not limited to rebuildAndRecalculate(). getSheetSerialized() returns [["={1,2}", 2]] before any rebuild happens. Any save-and-restore flow that round-trips through serialization corrupts array formulas the same way. rebuildAndRecalculate() is just the most visible trigger, because it performs that round trip internally.
Vertical spills fail identically. ={1;2} in A1 serializes as [["={1;2}"], [2]] and yields #SPILL! after a rebuild.
Ordinary formulas are unaffected. =A1+B1 survives a rebuild correctly, so the problem is specific to array formulas.
Reported downstream. This surfaced as handsontable/handsontable#11141. The Handsontable Formulas plugin also calls rebuildAndRecalculate() on its own, on the sheetAdded and sheetRemoved events, so Handsontable users can hit this without ever calling the API themselves — attaching a second grid to a shared engine breaks every array formula in the first grid.
Possibly related: #1287, which covers #SPILL! not clearing when the blocking area is freed. Same area, different defect.
Suggested fix
In getCellSerialized(), return undefined when the address belongs to an array vertex but is not that array's anchor cell, instead of falling through to getRawValue(). That makes the round trip idempotent for array formulas and fixes the save/restore case at the same time.
Demo
Reproduces in Node with no sandbox needed — the snippet under "Steps to reproduce" is complete and self-contained.
The original downstream report has a browser demo: https://stackblitz.com/edit/6sjfmr-eszi6u?file=index.js
HyperFormula version
Every version tested reproduces it: 2.4.0, 2.7.1, 3.0.0, 3.3.0, and 3.4.0 (latest).
Your framework
None — plain HyperFormula.
Your environment
Node.js 24 on macOS. Also reported in Chrome by the downstream reporter.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.8k
- Fork
- 174
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của handsontable/hyperformula
-
[Bug]: SUBSTITUTE expands dollar sequences in replacement textCó thể đã có người làm @vera-rubin đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
handsontable/hyperformula#1808 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
handsontable/hyperformula#1803 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
handsontable/hyperformula#1793 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: ADDRESS returns "!R2C3" when sheetName is empty (should return "R2C3")Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởBug Impact: Low
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 68/100
handsontable/hyperformula#1641 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 22/100
handsontable/hyperformula#1825 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của handsontable/hyperformula
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 75/100
siyuan-note/siyuan#20629 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Volume eject does not refuse system, root or /home mountsCó thể đã có người làm @bernardopg đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
spacedriveapp/spacedrive#3159 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
melgarafael/DeskcommCRM#3000 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
callstackincubator/simlock#639 ·
Maintainer thường phản hồi trong vòng 1 ngày