HF-131 (4/7): expose which function produced an error, and which argument - #1764
Open
marcin-kordas-hoc wants to merge 10 commits into
Open
marcin-kordas-hoc wants to merge 10 commits into
marcin-kordas-hoc wants to merge 10 commits into
Conversation
DetailedCellError.originFunction and .argumentIndex ride along from CellError, which already carried them internally since the origin/ propagation redesign -- this task is the public-exposure half. Two gaps found and closed while verifying, not assumed fixed by that earlier redesign: - FunctionPlugin.coerceArgumentsToRequiredTypes's two error-return sites never called withArgumentIndex, so a genuine per-argument coercion failure (e.g. `=DATE(2020,"x",1)`) reported argumentIndex: undefined instead of 1. Both sites now call it. - withArgumentIndex's gate checked only propagated/argumentIndex-already-set, missing the same originFunction check withOrigin already has. A nested call's own error (SQRT(-1) inside `=DATE(1,1,SQRT(-1))`) stamps its origin before DATE's own coercion loop ever sees it; without the extra guard that loop would still attach its own argument index to SQRT's error -- incoherent, since SQRT never had that argument. Verified via a same-formula, no-cell, no-propagation repro (the cross-cell version does not reproduce the bug, since the propagated gate alone already covers it). Every operator/function origin name asserted in the new specs was verified by direct probe against this worktree before being committed, including correcting one substituted-in test formula that turned out to exercise a different operator (multiply, not addWithEpsilon) than intended. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
Task linked: HF-131 Verbose and actionable formula error messages |
This was referenced Sep 10, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1bb9db5. Configure here.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperformula-docs | 624a8e4 | Commit Preview URL Branch Preview URL |
Sep 15 2026, 07:29 AM |
Performance comparison of head (624a8e4) vs base (915ca17) |
The doc predated the identities the later commits added, so it said a parsing error or a value typed into a cell reports undefined, when they report 'parser' and 'user input'. It now lists the vocabulary, and names the one case where an argument index can appear without an origin. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/hf-131-has-message #1764 +/- ##
===========================================================
+ Coverage 97.39% 97.40% +0.01%
===========================================================
Files 195 195
Lines 15844 15846 +2
Branches 3494 3494
===========================================================
+ Hits 15431 15435 +4
+ Misses 405 403 -2
Partials 8 8
🚀 New features to boost your workflow:
|
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.

What and why
Stacked on #1763. Exposes on the public
DetailedCellErrortype the two fields theorigin/propagation mechanism (introduced in #1762) already computes internally:
originFunction?: stringandargumentIndex?: number— which function or operator produced acell error, and, when it failed coercing one of its own arguments, which argument that was.
Revision note: an earlier version of this description said this PR built the mechanism
itself (the two choke points,
Cell.ts's builders, etc.). That was wrong — the mechanism landedin #1762 (see its revised description). This PR only does the public-facing exposure step the
mechanism commit's own message called out as a separate, later concern:
This PR is that boundary: expose the two fields, and wire the one direct caller outside the two
choke points.
What actually changes here (4 files, +32/-3):
src/CellValue.ts—DetailedCellErrorgainsoriginFunction/argumentIndex, copied from theunderlying
CellErrorin the constructor. Additive only: enumerable property count onDetailedCellErrorgrows from 5 (type/message/value/address/hasMessagefrom HF-131 (3/7): a consumer can tell 'no message' from 'empty message' #1763) to 7.src/interpreter/plugin/FunctionPlugin.ts—coerceArgumentsToRequiredTypes's two error-returnpaths (wrong-type, non-scalar) now call
.withArgumentIndex(i)— the only direct callers ofthat builder outside the two choke points HF-131 (2/7): the origin/propagation mechanism, plus the same guarantee outside the interpreter #1762 introduced.
src/Cell.ts—withArgumentIndex's no-op gate also checksoriginFunction !== undefined, notjust
argumentIndex: needed so a nested call's own error (SQRT(-1)inside=DATE(1,1,SQRT(-1))) doesn't getDATE's argument index attached after already claiming itsown origin.
CHANGELOG.md— documents the two new public fields.Verified against nested/propagated cases directly:
=SUM(SQRT(-1))reportsSQRT, notSUM;=1/0then=SUM(A1)reportsdivide,propagated: true, not re-claimed bySUM;=DATE(1,1,SQRT(-1))reports{originFunction: 'SQRT', argumentIndex: undefined}, not a leakedindex on
DATE's argument slot.Known, deliberate limit: a binary operator's error names the operator (
addWithEpsilon,divide, etc.), not which operand failed —argumentIndexis only set for a function's owncoercion loop; the two operands of a binary op have no equivalent loop. Not solved here.
Verified
npx tsc --noEmit— cleannpx eslint src/— 0 errorspre-existing branch-pinning mismatch as the rest of this stack
CellErrorconstruction sites insrc/(carried over from HF-131 (2/7): the origin/propagation mechanism, plus the same guarantee outside the interpreter #1762;re-confirmed at this branch's tip)
Stack
4 of 7 — stacked on #1763. Next:
fix/hf-131-rootless-origin.🤖 Generated with Claude Code
Note
Low Risk
Additive public fields on error export objects and small stamping logic; no changes to successful evaluation paths.
Overview
Exposes error provenance on the public API.
DetailedCellErrornow includesoriginFunctionandargumentIndex, copied from the internalCellErrorthat #1762 already populated — so consumers can see which function/operator produced an error and, when applicable, which argument failed coercion.Wires the last coercion stamping site.
FunctionPlugin.coerceArgumentsToRequiredTypesattaches.withArgumentIndex(i)on wrong-type and non-scalar coercion failures.Tightens
withArgumentIndex. It becomes a no-op onceoriginFunctionis set (not only whenargumentIndexorpropagatedis set), so nested errors likeSQRT(-1)insideDATE(1,1,...)keepSQRTas origin withoutDATE's argument index incorrectly attached.CHANGELOG documents the new fields alongside the existing
hasMessagework.Reviewed by Cursor Bugbot for commit 624a8e4. Bugbot is set up for automated code reviews on this repo. Configure here.
Performance
The hot-path change lives in #1762 and is measured there: total median −0.24% over three alternating
base/head rounds against
origin/develop, within the run-to-run spread, with one CRUD benchmark("Column ranges - add column") consistently about 3% slower. This PR adds fields to an object that
is only built when an error is exported, so it carries no measurable cost of its own.