Fix null crash in task schema fixReferences#306586
Merged
bryanchen-d merged 4 commits intomainfrom Apr 1, 2026
Merged
Conversation
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
bryanchen-d
approved these changes
Mar 31, 2026
Contributor
There was a problem hiding this comment.
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 !== nullguard when recursing through object properties infixReferencesto avoid dereferencingnull.
bpasero
approved these changes
Mar 31, 2026
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.
fixReferencesinjsonSchema_v2.tscrashes withCannot read properties of null (reading '$ref')when a task definition contributed by an extension containsnullproperty values.typeof null === 'object'in JS, so the object-property recursion path passesnullintofixReferences, which then dereferences it. The array-element path (line 21) already guards against this withelement !== null; the object-property path (line 31) was missing the same guard.