Fix to catch referenced errors in IFERROR/IFNA#275
Conversation
Formula references evaluate to ref nodes first, so IFERROR and IFNA were missing error sentinels already stored in referenced cells. Reuse the ERROR.TYPE error-value helper path so referenced formula errors are detected consistently.
📝 WalkthroughWalkthroughThis PR fixes error detection in ChangesError Detection Refactoring
Sequence DiagramsequenceDiagram
participant Formula as Formula Evaluation
participant Helper as errorValueFromNode
participant Grid as Grid
Formula->>Helper: errorValueFromNode(node, grid)
alt node is direct error
Helper-->>Formula: ErrValue
else node is reference
Helper->>Grid: lookup referenced cell
Grid-->>Helper: cell value
alt cell contains error
Helper-->>Formula: ErrValue
else cell is normal value
Helper-->>Formula: undefined
end
else no error
Helper-->>Formula: undefined
end
Formula->>Formula: decide fallback return
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
ggyuchive
left a comment
There was a problem hiding this comment.
LGTM. Thanks for your contribution.
Summary
ERROR.TYPE.IFERROR(A1, fallback)catch stored error sentinels from referenced cells.IFNA(A1, fallback)catch referenced#N/Awhile preserving other errors.Why
IFERRORandIFNAevaluate a cell reference to a ref node before the final result is rendered. That meant direct errors were caught, but a referenced cell whose stored value was an error sentinel leaked through. This keeps the behavior consistent withERROR.TYPE, which already treats stored formula error values as errors.Linked Issues
Fixes #273
Author checklist
Verification
CI automatically posts a verification summary comment on this PR with
per-lane results for both
verify:selfandverify:integration.Skip reason (if applicable):
Local verification:
pnpm --filter @wafflebase/sheets exec vitest run test/formula/formula.test.ts -t "IFERROR|IFNA|ERROR.TYPE"pnpm --filter @wafflebase/sheets typecheckTZ=UTC pnpm --filter @wafflebase/sheets testnpm audit signaturesgit diff --checkRisk Assessment
Notes for Reviewers
Summary by CodeRabbit
Release Notes
Bug Fixes
#N/Aerrors (replaced with fallback) and other errors (passed through) when using cell references.Tests