gl-vsts-tasks-file-patch icon indicating copy to clipboard operation
gl-vsts-tasks-file-patch copied to clipboard

Task fails with ambiguous error on JSON file that has comments

Open norvegec opened this issue 5 years ago • 1 comments

Before opening an issue please read this.

Are you reporting a bug or a feature request ?

  • [ ] Bug
  • [x] Feature request

Description

When JSON content of input file has comments the task fails with ambiguous message:

##[error]Couldn't apply patch to file: C:\myTargetDir\_configs\appsettings.dev.json
##[error]No files were patched.

Expected behavior

  • Good: output an error that would clearly point to a problem: "malformed JSON content" or "unsupported JSON content at line XXX", etc.
  • Better: ignore comments in JSON

Reproduction

Add this task (ver. 3/4) to a pipeline that works with filesystem (Azure Pipeline Windows 2019 agent pool) with options:

  • Syntax type: Slick Syntax,
  • Target files: appsettings.$(env).json
  • Patch content:
  • Output patched file in logs: checked
  • Fail if no files are patched: checked

and taking into account that file actually exist the task logs ambiguous error:

##[error]Couldn't apply patch to file: C:\myTargetDir\_configs\appsettings.dev.json
##[error]No files were patched."

# System information

**VSTS or TFS:**
* [x] VSTS
* [ ] TFS

**Agent:**
* [x] Hosted
* [ ] Custom

**OS:**
* [x] Windows
* [ ] Mac
* [ ] Linux


norvegec avatar Jun 30 '20 11:06 norvegec

Since then, I've discovered that JSON5 format is supported and works fine when corresponding option is checked. Maybe an error could give user a hint to use this flag?

norvegec avatar Jun 30 '20 11:06 norvegec