gl-vsts-tasks-file-patch
gl-vsts-tasks-file-patch copied to clipboard
Task fails with ambiguous error on JSON file that has 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
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?