Skip to content

Improve error for "TypeError: this.buffer.substring is not a function" #459

@ptrumpis

Description

@ptrumpis

Describe the bug

TypeError: this.buffer.substring is not a function
at Lexer.getLine (/usr/src/app/node_modules/yaml/dist/parse/lexer.js:208:28)
at Lexer.parseStream (/usr/src/app/node_modules/yaml/dist/parse/lexer.js:244:25)
at parseStream.next (<anonymous>)
at Lexer.parseNext (/usr/src/app/node_modules/yaml/dist/parse/lexer.js:226:36)
at parseNext.next (<anonymous>)
at Lexer.lex (/usr/src/app/node_modules/yaml/dist/parse/lexer.js:160:32)
at lex.next (<anonymous>)
at Parser.parse (/usr/src/app/node_modules/yaml/dist/parse/parser.js:159:20)
at parse.next (<anonymous>)
at Composer.compose (/usr/src/app/node_modules/yaml/dist/compose/composer.js:130:20)

To Reproduce
test.js

import YAML from 'yaml';
import * as fs from "fs/promises";

try {
    const file = await fs.readFile("config.yml");
    let config = YAML.parse(file);
} catch (e) {
    console.error(e);
}

config.yml

test:
  data:
    - foo
    - bar

Expected behaviour
I expected config.yml to be loaded and parsed to a JS object without error.

Versions:

  • Environment: Node.js 16 (Docker Image)
  • yaml: 2.2.1

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions