You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's the story so far: I'm futzing around with the heredoc support with Dockerfile syntax >=1.3, and it turns out to be excellent at applying small inline patches like so:
RUN <<END_OF_PATCH tee /dev/stderr | git apply
diff --git a/file b/file
....
END_OF_PATCH
That tee is in there because I was getting a strange "patch does not apply", and that's how I learned that the heredoc support is implemented entirely in the parsing front-end and gets turned into a carefully ARGV'd shell command:
ERROR: failed to solve: process "/bin/sh -c <<END_OF_PATCH tee /dev/stderr | git apply\ndiff --git
(NB: this isn't easily copy-pasteable because the shell that invokes /bin/sh will do word splitting and turn that into a mess, but that's another story)
What this means is that, since a heredoc acts much like a double-quoted shell string, metacharacters (i.e. $) were getting interpreted, changing the contents of my patch from something like - echo ${HELLO} to - echo <whatever value of HELLO was in the shell's environment, usually nothing>. Oops. Well, good thing there's a provision in the shell for a situation like this, I think, and I type this into my editor (on my way to turning the heredoc word into 'END_OF_PATCH'):
RUN <<'END_OF_PATCH tee /dev/stderr | git apply
and, to my surprise, the language server immediately crashes with this output:
TypeError: Cannot read properties of undefined (reading 'getRange')
at Run.getHeredocs (/home/seth/.vscode-oss/extensions/ms-azuretools.vscode-docker-1.26.1/dist/dockerfile-language-server-nodejs/lib/server.js:1:20724)
at Run.getHeredocs (/home/seth/.vscode-oss/extensions/ms-azuretools.vscode-docker-1.26.1/dist/dockerfile-language-server-nodejs/lib/server.js:1:28798)
at Validator.getHeredocLines (/home/seth/.vscode-oss/extensions/ms-azuretools.vscode-docker-1.26.1/dist/dockerfile-language-server-nodejs/lib/server.js:1:63517)
at Validator.validateInstruction (/home/seth/.vscode-oss/extensions/ms-azuretools.vscode-docker-1.26.1/dist/dockerfile-language-server-nodejs/lib/server.js:1:64127)
at Validator.validate (/home/seth/.vscode-oss/extensions/ms-azuretools.vscode-docker-1.26.1/dist/dockerfile-language-server-nodejs/lib/server.js:1:63270)
at Object.validate (/home/seth/.vscode-oss/extensions/ms-azuretools.vscode-docker-1.26.1/dist/dockerfile-language-server-nodejs/lib/server.js:1:102617)
at LanguageService.validate (/home/seth/.vscode-oss/extensions/ms-azuretools.vscode-docker-1.26.1/dist/dockerfile-language-server-nodejs/lib/server.js:1:219425)
at /home/seth/.vscode-oss/extensions/ms-azuretools.vscode-docker-1.26.1/dist/dockerfile-language-server-nodejs/lib/server.js:1:427396
In playing around with the demo site (very cool!), I got a similar-looking crash out of this minimal example:
RUN <<'END_OF_PATCHEND_OF_PATCH
That's definitely invalid syntax, so I'm not sure what the right response for the language server would be, but crashing on the input means that VS Code gives up after the 5th try (~instantaneously, since the startup is so fast).
The text was updated successfully, but these errors were encountered:
Hmm, you're right: that minimal example was too minimal, sorry. When I tried it again, I got the same crash in the demo site from the full Dockerfile (which I'm happy to provide, it's just A Lot), and narrowed it down to just this example that seems to crash every time I paste it into a freshly-loaded tab:
RUN <<'END_OF_PATCH
END_OF_PATCH
RUN <<'SCRIPT'
SCRIPT
@sethp Thank you very much for your new example! I am able to reproduce the bug and have opened rcjsuen/dockerfile-ast#114 to track this. I will leave this issue opened until the fix has been merged into the language server itself.
Here's the story so far: I'm futzing around with the heredoc support with Dockerfile syntax >=1.3, and it turns out to be excellent at applying small inline patches like so:
RUN <<END_OF_PATCH tee /dev/stderr | git apply diff --git a/file b/file .... END_OF_PATCH
That
tee
is in there because I was getting a strange "patch does not apply", and that's how I learned that the heredoc support is implemented entirely in the parsing front-end and gets turned into a carefully ARGV'd shell command:(NB: this isn't easily copy-pasteable because the shell that invokes
/bin/sh
will do word splitting and turn that into a mess, but that's another story)What this means is that, since a heredoc acts much like a double-quoted shell string, metacharacters (i.e. $) were getting interpreted, changing the contents of my patch from something like
- echo ${HELLO}
to- echo <whatever value of HELLO was in the shell's environment, usually nothing>
. Oops. Well, good thing there's a provision in the shell for a situation like this, I think, and I type this into my editor (on my way to turning the heredoc word into'END_OF_PATCH'
):and, to my surprise, the language server immediately crashes with this output:
In playing around with the demo site (very cool!), I got a similar-looking crash out of this minimal example:
That's definitely invalid syntax, so I'm not sure what the right response for the language server would be, but crashing on the input means that VS Code gives up after the 5th try (~instantaneously, since the startup is so fast).
The text was updated successfully, but these errors were encountered: