fix: enrich notebook model index error diagnostics and fix sort comparator (#301207)#302298
Merged
bryanchen-d merged 2 commits intomainfrom Mar 17, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an unhandled “model index out of range” error in notebook edit application by adding more diagnostic context to index validation and correcting edit ordering during application in NotebookTextModel.
Changes:
- Adds optional diagnostic context to
_assertIndexerror messages (including current cell count). - Validates index-based (non-Replace/non-Move) edits earlier during edit mapping, similar to handle-based validation.
- Adjusts the edit sorting comparator for
end === undefined(DocumentMetadata) edits.
7650036 to
5940edb
Compare
5940edb to
882573e
Compare
882573e to
e660fad
Compare
lramos15
approved these changes
Mar 17, 2026
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.
Fixes #301207
Problem
Unhandled error
model index out of range 11inNotebookTextModel._assertIndexprovides no diagnostic context — no cell count, no edit type, no indication of which lookup key produced the invalid index — making it difficult to determine the root cause from telemetry alone.Additionally, the sort comparator in
_doApplyEditsreturned-1whenb.end === undefined(DocumentMetadata edits), which incorrectly sorted them after cell-referencing edits instead of before them.Changes
Enrich
_assertIndexerror message — includecellCountand an optionalcontextstring so telemetry reports show the cell count and which edit type / lookup key triggered the failure.Pass context to
_assertIndexin the handle-lookup branch — so handle-based lookups also report diagnostic details.Fix sort comparator — change
return -1toreturn 1for theb.end === undefinedcase so DocumentMetadata edits (which have no cell index) sort before cell-referencing edits, matching the existinga.end === undefinedbranch.