Skip to content

TypeError: Cannot read property 'trim' of undefined #143

Description

@The-Compiler

When dockerfile_lint is passed a file with a line ending with a backslash, but no second line, such as this:

test \

it fails with:

TypeError: Cannot read property 'trim' of undefined
    at Object.parse (.../node_modules/dockerfile_lint/lib/parser.js:457:40)
    at Linter.validate (.../node_modules/dockerfile_lint/lib/linter.js:106:27)
    at lint (.../node_modules/dockerfile_lint/bin/dockerfile_lint:120:36)
    at .../node_modules/dockerfile_lint/bin/dockerfile_lint:129:13
    at new Promise (<anonymous>)
    at lintDockerFile (.../node_modules/dockerfile_lint/bin/dockerfile_lint:107:12)
    at .../node_modules/dockerfile_lint/bin/dockerfile_lint:86:16
    at Function.map (.../node_modules/lodash/dist/lodash.js:3509:27)
    at lintDockerFiles (.../node_modules/dockerfile_lint/bin/dockerfile_lint:82:26)
    at Object.<anonymous> (.../node_modules/dockerfile_lint/bin/dockerfile_lint:172:5)

The easiest way to reproduce is probably (with bash): dockerfile_lint -f <(echo 'test \\')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions