michaellzc / vscode-hadolint

VSCode extension to integrate hadolint, a Dockerfile linter, into VSCode
https://marketplace.visualstudio.com/items?itemName=exiasr.hadolint
MIT License
77 stars 5 forks source link

hadolint: Cannot read property 'toString' of null #57

Closed steffakasid closed 3 years ago

steffakasid commented 3 years ago

Describe the bug Receiving the following error message when opening Dockerfiles in VSCode: hadolint: Cannot read property 'toString' of null

To Reproduce Just open a Dockerfile

Expected behaviour Getting hadolint lint messages in Dockerfile

Environment and version (please complete the following information):

Debug information

Provide all output from hadolint (in the output console) while having an opened Dockerfile in VS Code.

It should produce something like this

[hadolint(34510) file:///Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash] Document is opened: file:///Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash/Dockerfile
[hadolint(34510) file:///Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash] Document is changed: file:///Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash/Dockerfile
[hadolint(34510) file:///Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash] Current settings: {"hadolintPath":"hadolint","cliOptions":["--no-color"],"maxNumberOfProblems":100,"outputLevel":"warning"}
[hadolint] Running hadolint /Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash/Dockerfile --no-color in /Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash
[hadolint(34510) file:///Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash] Current settings: {"hadolintPath":"hadolint","cliOptions":["--no-color"],"maxNumberOfProblems":100,"outputLevel":"warning"}
[hadolint] Running hadolint /Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash/Dockerfile --no-color in /Users/steffenrumpf/Projects/BuHu/bizhub-tools/bizhub-images/logstash

Additional information

Running hadolint Dockerfile for the same project just works fine.

michaellzc commented 3 years ago

Hi @steffakasid,

Thanks for reporting the issue.

Would you provide a minimal Dockerfile example that can consistently reproduce such behaviour? I have had no luck so far.

It's most likely that VS Code is just glitching as usual (things like Python plugin not indexing stuff or showing the right autocomplete suggestion), and running Developer: Reload Window should make these problems go away.

Unless the bug can be reproduced consistently, I am hesitant to put too much effort into it.

steffakasid commented 3 years ago

A minimal Dockerfile which hat the problem:

FROM logstash/logstash:7.13.4@sha256:281f04ed8cfc9a1c0eadcea26b6f094ef74d18c04914a2debf9cf5ecc33f407b
USER root
# hadolint ignore=DL3031
RUN yum update && yum upgrade
USER 1000
steffakasid commented 3 years ago

Could this be related to VSCode Insiders version?

steffakasid commented 3 years ago

Developer: Reload Window doesn't solve the issue

michaellzc commented 3 years ago

I am also running 1.60.0-insider with the exact same hadolint version in the system.

I sometimes run into errors where the language server (a part of the plugin) failed to read the content of Dockerfile from VS Code. However, the symptom is different than yours. You would have been seeing errors like length is not defined.

I suspect there are some weird bugs in the platform, either VS Code or the language server.

Would you try

PS It's pretty late in NA, so I'll take another look tomorrow.

steffakasid commented 3 years ago

No change at all. I've now also tried to disable all other Extensions I have. But still getting the error.

steffakasid commented 3 years ago

Ok now it works again. I had to set the full path to hadolint to /usr/local/bin/hadolint in the preferences.