fix: skip null drag entries during file upload (fixes #326644) - #326649
Merged
vs-code-engineering[bot] merged 1 commit intoJul 20, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot could not run the full agentic suite for this review because it was automatically requested on a bot-authored pull request. Request a review from Copilot under Reviewers to retry with the full agentic suite. Improved support for bot-authored pull requests is coming soon.
Updates drag-and-drop file import handling to account for webkitGetAsEntry() potentially returning null, preventing null entries from being processed downstream.
Changes:
- Updates
IWebkitDataTransferItem.webkitGetAsEntry()type to returnIWebkitDataTransferItemEntry | null. - Filters out
nullentries when building theentriesarray, with clarifying inline comments.
rzhao271
approved these changes
Jul 20, 2026
dmitrivMS
approved these changes
Jul 20, 2026
DonJayamanne
approved these changes
Jul 20, 2026
vs-code-engineering
Bot
deleted the
fix/upload-null-entry-326644-88273ae029d81eaf
branch
July 20, 2026 16:59
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.
Summary
TypeError: Cannot read properties of null (reading 'name')is thrown when dropping content onto the File Explorer that is not a file-system entry (e.g. dragged text, a URL, or non-file drag data).BrowserFileUpload.doUploadbuilds anentriesarray fromDataTransferItem.webkitGetAsEntry(), but that DOM API returnsFileSystemEntry | null— it returnsnullfor items that do not represent a file. The localIWebkitDataTransferIteminterface incorrectly declared the return type as non-nullable, so thenullwas pushed into an array typed asIWebkitDataTransferItemEntry[]. Later, the parallel upload callback readsentry.name(thefactoryframe in the stack) and crashes on thenullelement.This is a type-contract violation: the interface lied about the return type, letting a
nullbypass the type system at the producer (the array-building loop), and the crash surfaced far downstream atentry.name.Fixes #326644
Recommended reviewer:
@bpaseroCulprit Commit
The masking type declaration (
webkitGetAsEntry(): IWebkitDataTransferItemEntry) and theentries.push(item.webkitGetAsEntry())producer are long-standing infileImportExport.ts(the browser upload feature authored by@bpasero). No single recent commit introduced the null path; the telemetryrecent-regression/stable-anomalysignals reflect a change in drop-input mix rather than a code change to this file. Most recent touch to the file was7e8c7bef("debt - reduce explicitanyusage",@bpasero), which did not alter this behavior.Code Flow
flowchart TD A[HTMLDivElement drop handler] --> B[ExplorerDelegate.drop] B --> C[BrowserFileUpload.upload -> withProgress] C --> D[doUpload: entries.push webkitGetAsEntry] D -->|API returns null for non-file item| E[null pushed into entries array] E --> F[Limiter.queue callback / factory] F --> G[read entry.name on null -> TypeError]Affected Files
src/vs/workbench/contrib/files/browser/fileImportExport.ts— fix theIWebkitDataTransferItem.webkitGetAsEntryreturn type and skipnullentries when building the upload list.Repro Steps
webkitGetAsEntry()returnsnullfor that item; before the fix,doUploadpushed thenulland later readentry.name, throwingTypeError: Cannot read properties of null (reading 'name').How the Fix Works
Chosen approach (
src/vs/workbench/contrib/files/browser/fileImportExport.ts):IWebkitDataTransferItem.webkitGetAsEntryreturn type toIWebkitDataTransferItemEntry | null, matching the real DOM contract. This removes the type-system bypass that allowednullto enter a non-nullable array.doUpload, the array-building loop now captures the result and only pushes it when it is non-null, soentriesnever contains anull. This fixes the bug at the data producer (where the invalidnullis created) rather than guarding the crash site (entry.name), consistent with the fix-at-the-producer principle. Notry/catchis added and nologService.erroris touched.After this change, the
doUploadloop cannot place anullintoentries, so the downstreamentry.nameread can no longer receive anullelement.Alternatives considered:
entry.nameat the crash site (line 166 / thefactorycallback) — rejected because it patches the symptom downstream and leaves the mistyped interface producingnullfor every other consumer.Recommended Owner
@bpasero— original author of the browser file upload/import-export feature and most recent committer to this file.