0

I keep running into this YAML exception when using js-yaml to try to convert some yaml to json. I have multiple yaml files that contain a key/value that is a multi-line bit of yaml. I didn't write it and I'm not a big yaml user but it appears to be syntactically correct (even ran it thru a linter). For some reason it keeps choking. Below is an example of one of these files. Can someone tell me what I need to correct?

This is the error message I keep getting:

Invalid YAML file. YAMLException: end of the stream or a document separator is expected

JS file that converts over file:

      const readFile = yaml.load(fileContents);
      if (readFile.usage) {
        yamlLint
          .lint(readFile.usage)
          .then(() => {
            console.log("Valid YAML file.");
          })
          .catch((error) => {
            console.log(readFile.name, readFile.variant);
            console.error("Invalid YAML file.", error);
          });

Example key/value from yaml file:

usage: |
    ## Troubleshooting
    
    ### Error: `psycopg2.ProgrammingError: syntax error at or near "-"`
    
    This error message indicates that the extractor you are using this loader with generates
    stream names that include the source database schema in addition to the table name: `<schema>-<table>`, e.g. `public-accounts`.
    This is not supported by [this variant](#alternative-variants) of `target-postgres`.
    
    Instead, use the [`otherthing` variant](https://somewebsite.com) which was made to be used with extractors that behave this way.
    
    ### Error: `pg_config executable not found` or `libpq-fe.h: No such file or directory`
    
    This error message indicates that the [`libpq`](https://www.postgresql.org/docs/current/libpq.html) dependency is missing.
    
    To resolve this, refer to the ["Dependencies" section](#dependencies) above.
    
    ### `ld`, `clang`, `lssl`, or `linker` Errors
    
    If you have an error message like:
    
      * `ld: library not found for -lssl`
      * `clang: error: linker command failed with exit code 1`
      * `error: command 'clang' failed with exit status 1`
    
    These error messages indicates that there is a problem installing OpenSSL.
    
    This [Stack Overflow answer](https://stackoverflow.com/questions/26288042/error-installing-psycopg2-library-not-found-for-lssl)
    has specific recommendations on setting the `LDFLAGS` and/or `CPPFLAGS` environment variables.
    Set those prior to running `some CLI thingy`.
Alex Marple
  • 2,908
  • 4
  • 17
  • 24

0 Answers0