redhat-developer / redhat-developer/vscode-yaml

default value dollar sign is not completely escaped

Open
#952 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
829
Forks
260
Avg merge
5h 43m
Merged PRs (30d)
1

Description

Describe the bug

I think this is a follow up from https://github.com/redhat-developer/vscode-yaml/issues/258.

I have a schema with an default value that starts with an dollar sign. These values are in the root properties and in children properties.

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "foo": {
            "type": "object",
            "properties": {
                "bar": {
                    "type": "string",
                    "default": "$TEMP"
                }
            },
            "required": ["bar"]
        },
        "baz": {
            "type": "string",
            "default": "$TEMP"
        }
    },
    "required": ["foo", "baz"]
}

When I now add this schema to an file and try to create this file via CTRL+Space and Tab, I get the following preview and YAML.

image

foo:
  bar: 
baz: $TEMP

As you see from the yaml and the image, the $TEMP of baz gets escaped and will be correctly displayed in the yaml.
However, my bar value will not be displayed correctly.
It looks like the $ sign is not correctly escaped.

As a workaround, I could write "default": "\\$TEMP" in my schema, however this is not the perfect way, because baz is working correctly.

Expected Behavior

I expect that all my $ signs in the json schema will be escaped and not only the ones from the first properties.

Current Behavior

Currently only the first layer of properties will have escaped dollar signs, nested properties will not be escaped

Steps to Reproduce

  1. add the schema from above to VSCode
  2. Create a new file and use the above schema
  3. press CTRL+Space and tab to see the generated result

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the schema in the report by invoking VS Code completion with Ctrl+Space and Tab. Start at the schema-driven completion path and trace how dollar signs are escaped for nested properties such as foo.bar versus the root-level baz. Done means generated YAML preserves the $TEMP default at every nesting level.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.