Error "found unknown escape character" when rendering states for Windows hosts in VCF Salt
search cancel

Error "found unknown escape character" when rendering states for Windows hosts in VCF Salt

book

Article ID: 441465

calendar_today

Updated On:

Products

VCF Operations/Automation (formerly VMware Aria Suite)

Issue/Introduction

Error seen when running state:

  • Rendering SLS '<repo:module.state>' failed: found unknown escape character

If the above lists a particular line & character, pay attention to where this is.

Conditional logic may cause this to be encountered only for particular circumstances.

 

Environment

  • VMware Salt / RaaS / Aria Automation Config

Cause

The Windows path separator \ is interpreted by Unix-style software such as Salt, as an escape sequence.

Resolution

If Windows paths are given in the state files, enclose these in single quotes so that escape sequences are not processed.

Incorrect syntax:

This will cause \p, \t and \f to be interpreted as escape characters by Salt:

  • "C:\path\to\file"

Corrected syntax:

  • 'C:\path\to\file'

It is also possible to double-up backslashes (\\), but this may be more prone to mistakes than single-quoting the whole path.

Additional Information

The YAML specification states that escape sequences are "only interpreted in double-quoted scalars":

https://yaml.org/spec/1.2-old/spec.html#id2776092