This closes a panic on a worksheet with an empty merged cell reference - #2379
Merged
Conversation
The caching branch in mergeCellsParser is guarded on ref != "", so a mergeCell element with an empty ref never populates the cached rectangle and leaves it nil. The cellInRange call on the next line is unguarded and indexes that slice at four positions, so every non-streaming cell API panics on the first read after the file opens. Skip the entry when the rectangle is empty. checkCellInRangeRef used to return cleanly for this shape through its len(rng) != 2 guard, which was dropped in a34c81e when the cached-rect path replaced it. The streaming Rows and GetRows paths are unaffected, and GetMergeCells already errors cleanly through Rect(). Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2379 +/- ##
=======================================
Coverage 99.62% 99.62%
=======================================
Files 32 32
Lines 27005 27007 +2
=======================================
+ Hits 26905 26907 +2
Misses 52 52
Partials 48 48
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
xuri
approved these changes
Aug 20, 2026
xuri
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks for your contribution!
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.
Fix for the merged-cell panic reported privately.
mergeCellsParseronly populates the cached rectangle whenref != "", so a<mergeCell ref=""/>leavesrectnil, and thecellInRangecall immediately after is unconditional and indexes it at four positions.This skips the entry when the rectangle is empty.
checkCellInRangeRefhandled the same shape cleanly through itslen(rng) != 2guard before a34c81e replaced it with the cached-rect path.TestMergeCellsParsergains the empty-ref case alongside the existing nil-cell one. It panics without the change and passes with it. Fullgo test ./...is green, andgofmtandgo vetare clean.