Skip to content

Fix VSCode tasks.json parsing for tasks without explicit labels#47754

Merged
SomeoneToIgnore merged 1 commit intozed-industries:mainfrom
dastrobu:fix/vscode-tasks-optional-label
Feb 12, 2026
Merged

Fix VSCode tasks.json parsing for tasks without explicit labels#47754
SomeoneToIgnore merged 1 commit intozed-industries:mainfrom
dastrobu:fix/vscode-tasks-optional-label

Conversation

@dastrobu
Copy link
Contributor

Implements automatic label generation for VSCode tasks that don't have explicit 'label' fields, matching VSCode's behavior.

Changes:

  • Made label field optional in VsCodeTaskDefinition deserialization
  • Implemented custom deserializer to auto-generate labels:
    • npm tasks: 'npm: {script}' (e.g., 'npm: start')
    • shell tasks: first word of command (e.g., 'echo')
    • gulp tasks: 'gulp: {task}' (e.g., 'gulp: build')
    • fallback: 'Untitled Task'
  • Added test data file with tasks without labels
  • Added test cases

Closes #47749

Release Notes:

  • Fixed: VSCode tasks.json files with tasks missing explicit label fields now parse correctly. Labels are auto-generated matching VSCode's behavior (e.g., "npm: start").

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 27, 2026
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jan 27, 2026
@SomeoneToIgnore SomeoneToIgnore self-assigned this Feb 12, 2026
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thank you, this looks good but #47749 mentions more cases that this PR does not implement.

Yet, in the documentation link I see no such rules too, so quite confused: should we actually do what's proposed in the issue, what's in the PR, something else?

Can we have a link to the docs/sources with these rules?

Lastly, we want to test more conversion cases for coverage, even at the current PR's state.

@dastrobu dastrobu force-pushed the fix/vscode-tasks-optional-label branch from 33a190d to db18600 Compare February 12, 2026 15:13
@dastrobu
Copy link
Contributor Author

Thanks for the feedback!

Yet, in the documentation link I see no such rules too, so quite confused: should we actually do what's proposed in the issue, what's in the PR, something else?

The issue mentions grunt and typescript task types, but these aren't currently supported by Zed's parser. Adding label generation for them would require first implementing full parsing support. Here's what Zed currently handles:

enum Command {
    Npm {
        script: String,
    },
    Shell {
        command: String,
        #[serde(default)]
        args: Vec<String>,
    },
    Gulp {
        task: String,
    },
}

Can we have a link to the docs/sources with these rules?

Sure! Here's where VSCode implements this:

The core logic is in taskConfiguration.ts lines 1533-1547:
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts#L1533-L1547

if (result.configurationProperties.name) {
    result._label = result.configurationProperties.name;
} else {
    let label = result.configures.type;
    if (typeDeclaration.required && typeDeclaration.required.length > 0) {
        for (const required of typeDeclaration.required) {
            const value = result.configures[required];
            if (value) {
                label = label + ': ' + value;
                break;
            }
        }
    }
    result._label = label;
}

Basically: if there's no label field, VSCode takes the task type and appends the first required property value.

The task type definitions show what's required:

https://github.com/microsoft/vscode/blob/main/extensions/npm/package.json#L344-L360
https://github.com/microsoft/vscode/blob/main/extensions/gulp/package.json#L49-L69
https://github.com/microsoft/vscode/blob/main/extensions/grunt/package.json#L50-L71
https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/package.json#L1894-L1910
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts#L1574-L1576

if (!taskName) {
    context.problemReporter.error(nls.localize('ConfigurationParser.noTaskName',
        'Error: a task must provide a label property. The task will be ignored.\n{0}\n',
        JSON.stringify(external, null, 4)));
    return undefined;
}

This brings up the shell task question - the PR currently generates labels for shell tasks (using the first word of the command), but VSCode actually errors on these.

We have a few options:

  1. Match VSCode and reject shell tasks without labels
  2. Keep the current behavior (more permissive)
  3. Accept them but log a warning

I'd lean toward option 2 since it's more user-friendly and Zed already diverges from VSCode on which task types are supported. But what's your preference?

Lastly, we want to test more conversion cases for coverage, even at the current PR's state.

Done! I refactored the label generation into a standalone generate_label() function that can be tested independently.

Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thank you for sharing the context.

Seems reasonable to keep things as they are then, one last concern about the shell command:

Image

is it really ok to keep just the first word of the command?
I imagine there could be multiple echo or cargo or npm or whatnot and we'll have a conflict — instead, does it make sense to have the entire command as a label?

Implements automatic label generation for VSCode tasks that don't have
explicit 'label' fields, matching VSCode's behavior.

Changes:
- Made label field optional in VsCodeTaskDefinition deserialization
- Implemented custom deserializer to auto-generate labels:
  - npm tasks: 'npm: {script}' (e.g., 'npm: start')
  - shell tasks: first word of command (e.g., 'echo')
  - gulp tasks: 'gulp: {task}' (e.g., 'gulp: build')
  - fallback: 'Untitled Task'
- Added test data file with tasks without labels
- Added comprehensive test cases

Closes zed-industries#47749

Release Notes:

- Fixed: VSCode tasks.json files with tasks missing explicit `label`
  fields now parse correctly. Labels are auto-generated matching
  VSCode's behavior (e.g., "npm: start").
@dastrobu dastrobu force-pushed the fix/vscode-tasks-optional-label branch from db18600 to 1bd4a6c Compare February 12, 2026 16:18
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thanks!

@SomeoneToIgnore SomeoneToIgnore enabled auto-merge (squash) February 12, 2026 16:21
@dastrobu
Copy link
Contributor Author

is it really ok to keep just the first word of the command? I imagine there could be multiple echo or cargo or npm or whatnot and we'll have a conflict — instead, does it make sense to have the entire command as a label?

Good catch, improved it the way you suggested. Did a quick check what zed does with very long labels. No issue as far as I can see.
Just kept the fallback to "shell" for blank strings.

@SomeoneToIgnore SomeoneToIgnore merged commit 71de6ed into zed-industries:main Feb 12, 2026
27 checks passed
morgankrey added a commit that referenced this pull request Feb 19, 2026
Auto-applied queued documentation suggestions from:
- PR #48908
- PR #48909
- PR #48910
- PR #48912
- PR #48930
- PR #44794
- PR #48763
- PR #45073
- PR #48495
- PR #49374
- PR #49139
- PR #48780
- PR #48619
- PR #48978
- PR #48962
- PR #48988
- PR #47860
- PR #49015
- PR #47095
- PR #47475
- PR #48542
- PR #46766
- PR #47754
- PR #48807
- PR #44506
- PR #49051
- PR #49069
- PR #48842
- PR #48851
- PR #48736
- PR #47673
- PR #49094
- PR #49098
- PR #49622

Generated with script/docs-suggest-publish for human review in draft PR.
morgankrey added a commit that referenced this pull request Feb 25, 2026
Auto-applied queued documentation suggestions from:
- PR #48908
- PR #48909
- PR #48910
- PR #48912
- PR #48930
- PR #44794
- PR #48763
- PR #45073
- PR #48495
- PR #49374
- PR #49139
- PR #48780
- PR #48619
- PR #48978
- PR #48962
- PR #48988
- PR #47860
- PR #49015
- PR #47095
- PR #47475
- PR #48542
- PR #46766
- PR #47754
- PR #48807
- PR #44506
- PR #49051
- PR #49069
- PR #48842
- PR #48851
- PR #48736
- PR #47673
- PR #49094
- PR #49098
- PR #49622
- PR #49554
- PR #49710
- PR #49716
- PR #49732
- PR #49788
- PR #49876
- PR #49902
- PR #49910
- PR #49390
- PR #50027

Generated with script/docs-suggest-publish for human review in draft PR.
morgankrey added a commit that referenced this pull request Feb 25, 2026
Auto-applied documentation from:
- PR #48542: Bedrock extended context window
- PR #46766: LSP adapters in settings schema
- PR #47754: VSCode tasks.json label generation

Skipped (no target file exists):
- PR #49069: panel zoom state persistence

Already documented from prior batches:
- PR #48807, PR #44506, PR #49051, PR #48842, PR #48851, PR #48736
morgankrey added a commit that referenced this pull request Feb 25, 2026
Auto-applied queued documentation suggestions from:
- PR #48908
- PR #48909
- PR #48910
- PR #48912
- PR #48930
- PR #44794
- PR #48763
- PR #45073
- PR #48495
- PR #49374
- PR #49139
- PR #48780
- PR #48619
- PR #48978
- PR #48962
- PR #48988
- PR #47860
- PR #49015
- PR #47095
- PR #47475
- PR #48542
- PR #46766
- PR #47754
- PR #48807
- PR #44506
- PR #49051
- PR #49069
- PR #48842
- PR #48851
- PR #48736
- PR #47673
- PR #49094
- PR #49098
- PR #49622
- PR #49554
- PR #49710
- PR #49716
- PR #49732
- PR #49788
- PR #49876
- PR #49902
- PR #49910
- PR #49390
- PR #50027

Generated with script/docs-suggest-publish for human review in draft PR.
morgankrey added a commit that referenced this pull request Feb 25, 2026
Auto-applied documentation from:
- PR #48542: Bedrock extended context window
- PR #46766: LSP adapters in settings schema
- PR #47754: VSCode tasks.json label generation

Skipped (no target file exists):
- PR #49069: panel zoom state persistence

Already documented from prior batches:
- PR #48807, PR #44506, PR #49051, PR #48842, PR #48851, PR #48736
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VSCode tasks.json parser fails on valid tasks without explicit label field

2 participants