0
votes

Hello Developer Community!

I would like to ask for some help about the following, I have the following YAML data:

---
# yamllint disable rule:indentation rule:empty-lines
                      config_nsapp_cs_policy:
                      nsapp_cs_policy:

                          - policyname:                "url_app_preprd"
                            rule:                      "URL == \'/string/*\'"

When trying to run YAML lint against the YAML file, I get the following error:

  7:69      error    syntax error: found unknown escape character "'" (syntax)

Is it possible to define an exception rule for this specific linting rule (ignoring the problematic content in 'single quote')? I was thinking about completely disable / ignore YAML linting for the file as a whole, but it would not be the best approach. I do not know which YAML linting rule the single quote is matching. The single quote is expected in the line.

Thank You very much in advance!

1

1 Answers

4
votes

This is not a linter error, this is a parser error. Your input is invalid YAML because an escape sequence \' is not defined in YAML.

If the scalar content should simply contain single quotes, do

    rule: "URL == '/string/*'"

If the scalar content should also contain the backslashes, do

    rule: "URL == \\'/string/*\\'"

You can use a block scalar instead to avoid escaping the backslash:

    rule: >-
      URL == \'/string/*\'