Skip to content

Unable to abandon task with ${input} variable type command #255503

@rioj7

Description

@rioj7

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.101.0
  • OS Version: Win 11

The handling of the result of an ${input} variable type command in a tasks.json file has changed.

  "inputs": [
    {
      "id": "pickOption",
      "type": "command",
      "command": "myextension.pickOption",
      "args": {
        "description": "Pick an option"
      }
    }
  ]

It is no longer possible to abandon the task by returning undefined from the command.
If I use an ${input} variable type pickString in a tasks.json and I press Esc the task is abandoned.

  "inputs": [
    {
      "id": "pickOptionNative",
      "type": "pickString",
      "description": "Pick an option (Native)",
      "options": ["Option A", "Option B", "Option C", "Option D"]
    }
  ]

Looking at the source code: baseConfigurationResolverService.ts

The code for pickString returns undefined if the user abandons the quickPick, (line 322-329)

The code for command always returns: return { value: result, input: info };
This is correct if the return value of the command is a string, but not if it is undefined or null.

In commit 81775e7 (2025-03-11) it was:

						if (typeof result === 'string' || Types.isUndefinedOrNull(result)) {
							return result;
						}

In commit 4c95d54 (2025-03-18) it has changed to:

						if (typeof result === 'string' || Types.isUndefinedOrNull(result)) {
							return { value: result, input: info };
						}

Now an undefined result is treated as a valid result.
Better would this be to change it to:

						if (typeof result === 'string') {
							return { value: result, input: info };
						}
						if (Types.isUndefinedOrNull(result)) {
							return undefined;
						}

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bughelp wantedIssues identified as good community contribution opportunitiestasksTask system issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions