From ebbc16c20b2115ff3da712dc7e9ccd245bcbd8d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 31 Mar 2026 04:08:54 +0000 Subject: [PATCH] Fix null check in fixReferences to prevent crash on null property values The fixReferences function in jsonSchema_v2.ts would crash with "Cannot read properties of null (reading '$ref')" when a task definition from an extension contained null property values. typeof null === 'object' in JavaScript, so the guard on line 31 would pass for null values, causing a recursive call into null. The array element path (line 21) already had a null check but the object property path was missing it. Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/97290369-e210-4404-b2b7-7c8ca4a2f84b Co-authored-by: bryanchen-d <41454397+bryanchen-d@users.noreply.github.com> --- src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts index 56eb132182a..4547a8ee4d3 100644 --- a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts +++ b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts @@ -28,7 +28,7 @@ function fixReferences(literal: Record | unknown[]) { } Object.getOwnPropertyNames(literal).forEach(property => { const value = literal[property]; - if (Array.isArray(value) || typeof value === 'object') { + if (Array.isArray(value) || (typeof value === 'object' && value !== null)) { fixReferences(value as Record); } });