question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unknown escape sequence when trying to validate yaml file in a directory path

See original GitHub issue

I used create-openapi-repo to create a brand new repo. Then I ran $ npm start

This tries to validate the openapi/openapi.yaml file and the openapi-cli validate failed to resolve the escape character of the path separator. Is this a Windows issue? How do I solve this?

Thanks!

Env:  On Windows using Git Bash
$ node -v
v12.16.1
$ npm -v
6.14.3

$ openapi validate openapi/openapi.yaml

C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:173
  throw generateError(state, message);
  ^
YAMLException: unknown escape sequence at line 3, column 18:
      main: "openapi\openapi.yaml"
                     ^
    at generateError (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:167:10)
    at throwError (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:173:9)
    at readDoubleQuotedScalar (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:646:9)
    at composeNode (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1365:13)
    at readBlockMapping (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1089:11)
    at composeNode (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1359:12)
    at readBlockMapping (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1089:11)
    at composeNode (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1359:12)
    at readDocument (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1519:3)
    at loadDocuments (C:\Users\qhvu\AppData\Roaming\npm\node_modules\@redocly\openapi-cli\node_modules\js-yaml\lib\js-yaml\loader.js:1575:5) {
  name: 'YAMLException',
  reason: 'unknown escape sequence',
  mark: Mark {
    name: null,
    buffer: '# See https://docs.redoc.ly/cli/configuration/ for more information.\r\n' +
      'apiDefinitions:\r\n' +
      '  main: "openapi\\openapi.yaml"\r\n' +
      'lint:\r\n' +
      '  rules:\r\n' +
      '    no-unused-schemas: warning\r\n' +
      'referenceDocs:\r\n' +
      '  htmlTemplate: ./docs/index.html\r\n' +
      '  theme:\r\n' +
      '    colors:\r\n' +
      '      primary:\r\n' +
      '        main: "#32329f"\n' +
      '\u0000',
    position: 104,
    line: 2,
    column: 17
  },
  message: 'unknown escape sequence at line 3, column 18:\n' +
    '      main: "openapi\\openapi.yaml"\n' +
    '                     ^'
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RomanHotsiycommented, Apr 15, 2020

We should fix the generator code to not produce a file path with \ in the first place

0reactions
adamaltmancommented, Jul 9, 2020

I opened the issue in Redocly/create-openapi-repo, and I’m going to close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unknown escape sequence when trying to validate yaml file in ...
This tries to validate the openapi/openapi.yaml file and the openapi-cli validate failed to resolve the escape character of the path separator.
Read more >
YAML, linting - syntax error - unknown escape character
This is not a linter error, this is a parser error. Your input is invalid YAML because an escape sequence \' is not...
Read more >
Found unexpected or unknown characters - Elastic
If the YAML file contains paths with spaces or unusual characters, wrap the paths in single quotation marks (see Wrap paths in single...
Read more >
Error parsing YAML config file: yaml-cpp - DBA Stack Exchange
YAML interprets backslashes inside quoted strings as introducing an escape character, so reports: "error at line 3, column 16: unknown ...
Read more >
regex in yaml file - Google Groups
I am attempting to use regex in a yaml automation file for docker to exclude a path. When attempting with these options: excludePaths:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found