Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Parsing failure when tasks.json contains comments #4377

Closed
lonix1 opened this issue Feb 3, 2021 · 6 comments · Fixed by #6288
Closed

[Bug] Parsing failure when tasks.json contains comments #4377

lonix1 opened this issue Feb 3, 2021 · 6 comments · Fixed by #6288
Assignees
Milestone

Comments

@lonix1
Copy link

lonix1 commented Feb 3, 2021

Environment data

latest of everything
linux
sdk: 5.0.102
vscode: 1.52.1
c# extension: 1.23.8

Problem

When opening a project, I get a popup error:

Failed to parse tasks.json file

Sample

This is .vscode/tasks.json which is a jsonc file:

// this comment is allowed
{
  // this comment is allowed
  "version": "2.0.0",
  "tasks": [
    {
      // this comment is allowed
      "label": "run",
      "type": "process",
      "command": "dotnet",             // this comment is allowed
      "args": [
        "run",
        "--project",
        "${workspaceFolder}/src/Foo/Foo.csproj",
        //"--launch-profile", "Production",           // <<<<<<<<<< THIS IS THE PROBLEM
      ],
    },
  ],
  // this comment is allowed
}

The comment inside the args array is the problem. When removed, there is no error.

@lonix1 lonix1 closed this as completed Apr 30, 2022
@lonix1 lonix1 reopened this May 1, 2022
@JoeRobich
Copy link
Member

@lonix1 Sorry we didn't respond to this issue earlier. I believe it is VS Code sending your this error popup. I think you will want to report this issue at https://github.com/microsoft/vscode/issues

@lonix1
Copy link
Author

lonix1 commented May 4, 2022

Thanks I've done that.

@lonix1 lonix1 closed this as completed May 4, 2022
@lonix1
Copy link
Author

lonix1 commented May 8, 2022

Apparently they don't think it's a vscode issue.

One more thing, the error popup shows this:

Failed to parse tasks.json file
Source: C# (Extension) <----------

Any thoughts?

@lonix1 lonix1 reopened this May 8, 2022
@spencer741
Copy link

spencer741 commented Feb 24, 2023

+1 I am still seeing this issue on latest omnisharp.

Proof that it is the omnisharp extension: If you restart the omnisharp server, the error message pops up again.

@JoeRobich

@lonix1
Copy link
Author

lonix1 commented Aug 25, 2023

UPDATE

I'm now using the new c# extension (v2+).

Unlike in the bug reproduction above, I no longer have a comment in an "args" array, but the problem remains because when I open the workspace I get the same error:

Failed to parse tasks.json file
Source: C# (Extension)

I tracked down the problem:

// allowed
{
  // allowed
  "version": "2.0.0",         // allowed
  "tasks": [

    // allowed
    {
      "label":   "foo",       // ERROR!  <<<<<<<<<<<<<<<<<<<
      "type":    "shell",
      "command": "true",
      // ERROR!                          <<<<<<<<<<<<<<<<<<<
    },

  ],
}
// allowed

Any comment inside a task hash will trigger this problem. (So actually it's worse than before, because this didn't happen before.)

So the parser doesn't fully respect jsonc: it allows trailing commas, and comments in most places, just not inside the task hashes.

Our tasks file (like most of our code) is heavily commented, so this is a real nuisance, and has been for years.

@jasonmalinowski I hope it's ok that I hijacked my own issue with the new reproduction details? An info you need from me just let me know.

@lonix1 lonix1 changed the title [Bug] Parsing failure when tasks.json contains comment in args array [Bug] Parsing failure when tasks.json contains comments Aug 25, 2023
@jasonmalinowski
Copy link
Member

@lonix1 Fine in this case, since it does look to be the same issue.

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 a pull request may close this issue.

5 participants