Skip to content

fix(HF-135): enforce array dimensions and spill boundaries - #1774

Open
Tobiadefami wants to merge 1 commit into
developfrom
fix/HF-135
Open

Tobiadefami wants to merge 1 commit into
developfrom
fix/HF-135

Conversation

@Tobiadefami

@Tobiadefami Tobiadefami commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Guard predicted array dimensions before mapping cells and check actual dimensions before VSTACK, HSTACK, TRANSPOSE and inline-array concatenation allocate oversized results. Return #VALUE! when maxRows or maxColumns is exceeded, including for intermediate arrays. Reuse the existing SEQUENCE dimension guards and preserve whole-row/column reference behavior.

Also return #SPILL! when valid result dimensions extend beyond the sheet edge from the formula's position. With maxRows set to 4, SEQUENCE(4) in A2 needs A2:A5 and now returns #SPILL!; the same formula still fits at A1.

Document both boundary checks.

Context

How did you test your changes?

Types of changes

  • Breaking change (a fix or a feature because of which an existing functionality doesn't work as expected anymore)
  • New feature or improvement (a non-breaking change that adds functionality)
  • Bug fix (a non-breaking change that fixes an issue)
  • Additional language file, or a change to an existing language file (translations)
  • Change to the documentation

Related issues:

  1. Fixes #...

Checklist:

  • I have reviewed the guidelines about Contributing to HyperFormula and I confirm that my code follows the code style of this project.
  • I have signed the Contributor License Agreement.
  • My change is compliant with the OpenDocument standard.
  • My change is compatible with Microsoft Excel.
  • My change is compatible with Google Sheets.
  • I described my changes in the CHANGELOG.md file.
  • My changes require a documentation update.
  • My changes require a migration guide.

Note

Medium Risk
Touches core array sizing, dependency-graph spill logic, and formula evaluation paths; behavior changes for oversized or edge-spilling formulas may affect existing sheets that previously allowed invalid arrays.

Overview
Enforces maxRows and maxColumns for array results end-to-end: predicted spill sizes are capped in ArraySizePredictor, runtime allocation is guarded for VSTACK, HSTACK, TRANSPOSE, SEQUENCE, and inline {…} literals, all returning #VALUE! (Value too large.) when a dimension exceeds config—including intermediate arrays (e.g. oversized VSTACK inside SUM cannot be hidden behind a scalar wrapper).

When dimensions are valid but the spill rectangle would extend past the sheet from the formula cell, DependencyGraph.isThereSpaceForArray now treats over-limit ranges like insufficient space, yielding #SPILL! (No space for array result.). Whole-row/column references still use infinite dimensions at predict time.

Documentation and CHANGELOG describe the two checks (config limits vs. placement).

Reviewed by Cursor Bugbot for commit ea75425. Bugbot is set up for automated code reviews on this repo. Configure here.

@cla-external-contractor-signup

Copy link
Copy Markdown

@Tobiadefami thanks for the pull request. No CLA step needed here — our records show you signed the Contributor License Agreement on 2026-07-31. That signature came from our previous signing form and has been carried over, so there is nothing for you to re-sign.

@qunabu

qunabu commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7820d3c. Configure here.

Comment thread CHANGELOG.md Outdated
Guard predicted array dimensions before mapping cells and check actual
dimensions before VSTACK, HSTACK, TRANSPOSE and inline-array concatenation
allocate oversized results. Return #VALUE! when maxRows or maxColumns is
exceeded, including for intermediate arrays. Reuse the existing SEQUENCE
dimension guards and preserve whole-row/column reference behavior.

Also return #SPILL! when valid result dimensions extend beyond the sheet
edge from the formula's position. With maxRows set to 4, SEQUENCE(4) in A2
needs A2:A5 and now returns #SPILL!; the same formula still fits at A1.

Document both boundary checks.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 15, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
hyperformula-docs ea75425 Commit Preview URL

Branch Preview URL
Sep 15 2026, 06:02 PM

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

Performance comparison of head (ea75425) vs base (c920375)

                                     testName |    base |    head | change
--------------------------------------------------------------------------
                                      Sheet A |   486.6 |  494.53 | +1.63%
                                      Sheet B |   156.1 |   156.7 | +0.38%
                                      Sheet T |   135.7 |  138.29 | +1.91%
                                Column ranges |  516.56 |  521.37 | +0.93%
                                Sorted lookup | 14599.4 | 15739.4 | +7.81%
Sheet A:  change value, add/remove row/column |   16.58 |    17.9 | +7.96%
 Sheet B: change value, add/remove row/column |   138.6 |  136.11 | -1.80%
                   Column ranges - add column |  161.65 |  160.22 | -0.88%
                Column ranges - without batch |  519.95 |  499.19 | -3.99%
                        Column ranges - batch |  127.76 |  122.69 | -3.97%

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.34%. Comparing base (c920375) to head (ea75425).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1774      +/-   ##
===========================================
+ Coverage    97.32%   97.34%   +0.01%     
===========================================
  Files          195      195              
  Lines        15739    15758      +19     
  Branches      3390     3470      +80     
===========================================
+ Hits         15318    15339      +21     
+ Misses         421      411      -10     
- Partials         0        8       +8     
Files with missing lines Coverage Δ
src/ArraySize.ts 100.00% <100.00%> (ø)
src/DependencyGraph/DependencyGraph.ts 98.81% <100.00%> (+<0.01%) ⬆️
src/interpreter/Interpreter.ts 96.07% <100.00%> (+0.71%) ⬆️
src/interpreter/plugin/ArrayPlugin.ts 99.20% <100.00%> (+0.03%) ⬆️
src/interpreter/plugin/MatrixPlugin.ts 98.72% <100.00%> (+0.01%) ⬆️
src/interpreter/plugin/SequencePlugin.ts 98.52% <100.00%> (+0.02%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants