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>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-31 04:08:54 +00:00
committed by GitHub
parent eaf6f5ee14
commit ebbc16c20b

View File

@@ -28,7 +28,7 @@ function fixReferences(literal: Record<string, unknown> | 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<string, unknown>);
}
});