microsoft / microsoft/vscode-containers

Erroneous "failed to process string" error and syntax highlighting for Dockerfile parameter substitution modifier `-`

Open
#184 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

language-server
Dominant language
TypeScript
Stars
139
Forks
87
Avg merge
9h 15m
Merged PRs (30d)
9

Description

I'm getting an erroneous error message for the following string:

"failed to process "${HTTP_PROXY-http://corporate-proxy.com:8080}": unsupported modifier (/) in substitution dockerfile-utils(44)

This string replacement is in fact not an error, - is recognized as a valid environment replacement modifier and / is interpreted as the literal character, not a substitution modifier, when performing the substitution (see: https://github.com/docker/docs/issues/23165).

It appears that this is also breaking syntax highlighting.

Image

Tested and confirmed locally:

# Dockerfile
ARG HTTP_PROXY
ENV http_proxy=${HTTP_PROXY-http://corporate-proxy.com:8080}
RUN echo $http_proxy

# No build arg
$ docker build -f Dockerfile .
> http://corporate-proxy.com:8080

# Build arg null
$ docker build --build-arg HTTP_PROXY="" -f Dockerfile .
> 

# Build arg value
$ docker build --build-arg HTTP_PROXY="override" -f Dockerfile .
> override

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported Dockerfile example with the three HTTP_PROXY cases and inspect the Dockerfile processing and syntax-highlighting entry points that report dockerfile-utils(44). Confirm that the '-' modifier accepts the URL containing '/', then verify that the diagnostic disappears and the substitution is highlighted correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
dockerfile
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.