Skip to content

Reject out-of-range numeric filterBy columns instead of overflowing (#573) - #591

Merged
h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
MarekSpodBiedry:issue-573
Oct 13, 2026
Merged

h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
MarekSpodBiedry:issue-573

Conversation

@MarekSpodBiedry

Copy link
Copy Markdown
Contributor

Fixes #573.

data.filterBy accepts a 0-based numeric column offset. col_param turned it into a column with base + o as u32. The as cast truncated a u64 silently, and the addition could overflow before the range check ran. In a debug build the overflow panicked, and the session sent back an internal error instead of the usual parameter error.

Changes:

  • col_param now uses u32::try_from and checked_add, so a number that cannot be a column returns None instead of overflowing.
  • filter_by reports a numeric column that does not fit as column outside the filter range, the same error a small out-of-range offset such as 2 or the letter "D" already gets. A missing or non-numeric column still returns missing \column``.

The other col_param callers (sort, removeDuplicates, subtotal) also stop overflowing. A huge number there goes through the same path an unusable column already takes in each of them, so their behaviour for valid input does not change.

Test: filter_by_huge_numeric_column_is_rejected_not_overflowed uses the issue's setup (B1:C3 with an AutoFilter). It checks that 2, u32::MAX and u64::MAX all return the parameter error, and that the valid offset 0 still hides exactly one row. Without the fix, u32::MAX overflows and the test fails.

@MarekSpodBiedry
MarekSpodBiedry marked this pull request as ready for review October 12, 2026 06:53
# Conflicts:
#	crates/engine/src/cmd/data.rs
@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 7357a90 into storytold:main Oct 13, 2026
1 check passed
@echelon

echelon commented Oct 13, 2026

Copy link
Copy Markdown
Member

Merged — thank you @MarekSpodBiedry for the contribution!

I merged main into your branch and resolved the conflicts with PRs that landed first (and adjusted tests where the combination needed it).

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.

fix(data): numeric filter offsets can return an internal error before validation

3 participants