Tolerate a null file in DelayedFileSource - #3370
Open
FrayxRulez wants to merge 1 commit into
Open
Conversation
A sticker with no StickerValue leaves _file null, which every other member of the hierarchy already supports, so hashing the source crashed on Id. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
NullReferenceException— "Object reference not set to an instance of an object", reported by crash telemetry on 12.9.1.0.Cause
A
DelayedFileSourcebuilt from a sticker whoseStickerValueis null ends up with a null_file. That is a supported state everywhere else in the hierarchy — the constructor guardsif (file != null),FilePathandIsDownloadingCompleteduse_file?.,LocalFileSourcereturns early on a null file, and all four delayed subclasses overrideIdbecause their_filestarts null. The baseIdwas the one accessor that dereferenced it unconditionally, andGetHashCode(HashCode.Combine(Id, IsAnimated)) makes it unavoidable as soon asAnimatedImageLoader.GetOrCreatehashes the presentation. The crashing instance is the base class, not a subclass.EmojiDrawerViewModeldeliberately inserts placeholder stickers with a nullStickerValue, so this is reachable from the emoji drawer.Change
DelayedFileSource.Idfalls back to0on a null file, matchingLocalFileSource, whoseIdis left at0for exactly this case.DelayedFileSource.DownloadFilereturns early on a null file instead of dereferencing it three times. Subclasses fully override this method to resolve the file themselves, so nothing in that path is lost.EmojiDrawer's "+N" expand path assigns a file source without theStickerValue != nullcheck that its two sibling call sites in the same file already have; added.Not built — a .NET Native build isn't available here. Both files parse clean under
CSharpSyntaxTree.ParseText(...).GetDiagnostics(), which catches syntax errors and nothing more.🤖 Generated with Claude Code