Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows paths in List Format result in: "found unknown escape character. Exiting." or "found unexpected ':'. Exiting." #1495

Closed
PhaedrusTheGreek opened this issue Apr 26, 2016 · 7 comments

Comments

@PhaedrusTheGreek
Copy link
Contributor

The certificate_authorities line in this configuration is invalid:

output:
  logstash:
    hosts: ["localhost:5045"]
    tls:
      certificate_authorities: [C:\Program Files\Filebeat\certs\filebeat.crt]
      certificate: C:\Program Files\Filebeat\certs\filebeat.crt
      certificate_key: C:\Program Files\Filebeat\certs\filebeat.key

Causes:

... found unexpected ':'. Exiting.

As is this:

      certificate_authorities: ["C:\Program Files\Filebeat\certs\filebeat.crt"]

Causes:

... found unknown escape character. Exiting.

The only way to get it to load is by escaping the backslashes, which seems inconsistent being that the only difference is that certificate_authorities requires a list format.

certificate_authorities: ["C:\\Program Files\\Filebeat\\certs\\filebeat.crt"]

Related: http://stackoverflow.com/questions/34513913/unable-to-start-filebeat-due-to-yaml-config-issue

@ruflin ruflin added libbeat and removed Filebeat Filebeat labels Apr 27, 2016
@ruflin
Copy link
Member

ruflin commented Apr 27, 2016

@urso Is this actually a bug or just a YAML problem?

@andrewkroh
Copy link
Member

I think you can avoid this problem by using a forward slash in your Windows paths (Golang does the right thing and converts them IIRC) or instead of using double quotes, use single quotes.

@PhaedrusTheGreek
Copy link
Contributor Author

@andrewkroh - this is confirmed that single quotes with forward slashes in arrays is accepted:

output:
  logstash:
    hosts: ["somehost:5045"]
    tls:
      certificate_authorities: ['C:/Program Files/Filebeat/certs/filebeat.crt']
      certificate: C:\Program Files\Filebeat\certs\filebeat.crt
      certificate_key: C:\Program Files\Filebeat\certs\filebeat.key

@PhaedrusTheGreek PhaedrusTheGreek added docs and removed bug labels Aug 8, 2016
@andrewkroh
Copy link
Member

I propose we resolve this issue by adding a special note to Windows users in our docs describing the options for specifying paths in YAML files. I was thinking to put it into the "Configuring *beat" section of the Getting Started guide for each beat, like this page for Filebeat. Or maybe an FAQ topic?

It would probably easiest to recommend using single quotes around any Windows path. That addresses any issue caused by the colon in absolute paths and avoids the need to escape any back-slashes.

// cc: @dedemorton

@dedemorton
Copy link
Contributor

@andrewkroh It wouldn't hurt to mention this in a few places: in the config section of each GS and where we mention specifying a path. An FAQ topic is also a good idea, especially if "found unknown escape character" generally means that you've specified a Windows path that uses backslashes. I'll assign this item to myself and play it by ear (don't want to repeat this a bazillion times, but wan to make sure that users don't overlook it).

@dedemorton dedemorton self-assigned this Aug 11, 2016
@urso
Copy link

urso commented Mar 27, 2017

I'm advocating use of single-quotes for paths and regular expressions for quite some time now.
YAML has 5 different kind of strings, each with slightly different semantics (yay). Using single quotes ensures the YAML parser is not interpreting the string-contents in any way. As long as you don't need a ' symbol in your string, always use single-quotes for things like paths and regular expressions. Otherwise you have to use double-quotes with additional escaping.

Windows path with C:/ ... add another quirk/ambiguity... as raw unquoted string followed by : must be parsed as dictionary in YAML (according to spec). The spec/parser is not guessing between windows-file-path and valid YAML dictionary. That is, windows paths starting with a drive letter must always be quoted.

All this behaviour is by (YAML) design/specification. For as long as we're using YAML, the best solution is to use single-quotes consistently.

@dedemorton
Copy link
Contributor

I've added #3882 to address this problem

The following dev PR should also help users: #3781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants