Skip to content

Fix null crash in task schema fixReferences#306586

Merged
bryanchen-d merged 4 commits intomainfrom
copilot/fix-null-reference-error
Apr 1, 2026
Merged

Fix null crash in task schema fixReferences#306586
bryanchen-d merged 4 commits intomainfrom
copilot/fix-null-reference-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

fixReferences in jsonSchema_v2.ts crashes with Cannot read properties of null (reading '$ref') when a task definition contributed by an extension contains null property values.

typeof null === 'object' in JS, so the object-property recursion path passes null into fixReferences, which then dereferences it. The array-element path (line 21) already guards against this with element !== null; the object-property path (line 31) was missing the same guard.

- if (Array.isArray(value) || typeof value === 'object') {
+ if (Array.isArray(value) || (typeof value === 'object' && value !== null)) {

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>
Copilot AI changed the title [WIP] Fix regression - Cannot read properties of null Fix null crash in task schema fixReferences Mar 31, 2026
Copilot AI requested a review from bryanchen-d March 31, 2026 04:09
@bryanchen-d bryanchen-d marked this pull request as ready for review March 31, 2026 04:33
Copilot AI review requested due to automatic review settings March 31, 2026 04:33
@bryanchen-d bryanchen-d enabled auto-merge March 31, 2026 04:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a runtime crash in the tasks JSON schema “reference patching” logic (fixReferences) when task definitions contributed by extensions include null property values, preventing null from being recursed into as an object.

Changes:

  • Add an explicit value !== null guard when recursing through object properties in fixReferences to avoid dereferencing null.

@bryanchen-d bryanchen-d merged commit eac55d8 into main Apr 1, 2026
18 checks passed
@bryanchen-d bryanchen-d deleted the copilot/fix-null-reference-error branch April 1, 2026 01:16
@vs-code-engineering vs-code-engineering bot added this to the 1.115.0 milestone Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Regression] Cannot read properties of null (reading '$ref')

4 participants