Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile ARG default throws NPE if ARG is null #1528

Closed
twendelmuth opened this issue Feb 23, 2022 · 4 comments · Fixed by #1529
Closed

Dockerfile ARG default throws NPE if ARG is null #1528

twendelmuth opened this issue Feb 23, 2022 · 4 comments · Fixed by #1529
Assignees

Comments

@twendelmuth
Copy link
Contributor

Description

It seems like if you're building a Dockerfile with ARG and defining a default like ARG TEST=test and pass <TEST></TEST> to the plugin, this will fail with NullpointerException in https://github.com/fabric8io/docker-maven-plugin/blob/master/src/main/java/io/fabric8/maven/docker/util/DockerFileUtil.java#L268

Info

  • docker-maven-plugin version : 0.39.0

  • pom.xml configuration

			<plugin>
				<groupId>io.fabric8</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<version>0.39.0</version>

				<configuration>
					<images>
						<image>
							<name>example-image</name>
							<build>
								<contextDir>example</contextDir>
								<args>
									<TEST></TEST>
								</args>
							</build>
						</image>
					</images>
				</configuration>
			</plugin>

  • Example Dockerfile:
FROM alpine
ARG TEST=something

The example is obviously not what is happening in the end (with that you could just ask me to remove the arg if I'm not setting it, but rather the problem that I have another variable in there which potentially is not set)

@rohanKanojia
Copy link
Member

@twendelmuth : Hi, was this working before v0.39.0 . I'm afraid it might be due to #1524

Would it be possible for you to raise a PR to fix this?

twendelmuth added a commit to twendelmuth/docker-maven-plugin that referenced this issue Feb 23, 2022
twendelmuth added a commit to twendelmuth/docker-maven-plugin that referenced this issue Feb 23, 2022
…exists but value is null

Signed-off-by: thorsten.wendelmuth <thorsten.wendelmuth@gmx.de>
@twendelmuth
Copy link
Contributor Author

twendelmuth commented Feb 23, 2022

@rohanKanojia Sure. I don't think this was working before though. 0.38.0 & 0.38.1 both throw the same NPE, 0.37.0 just throws a more descriptive exception ;)

Execution default-cli of goal io.fabric8:docker-maven-plugin:0.37.0:build failed: null value in entry: TEST=null

rohanKanojia pushed a commit to twendelmuth/docker-maven-plugin that referenced this issue Feb 24, 2022
…exists but value is null

Signed-off-by: thorsten.wendelmuth <thorsten.wendelmuth@gmx.de>
rohanKanojia pushed a commit that referenced this issue Feb 24, 2022
…t value is null

Signed-off-by: thorsten.wendelmuth <thorsten.wendelmuth@gmx.de>
@flocard02
Copy link

Hello,

Looks like the issue is still here

Execution fabric8-build of goal io.fabric8:docker-maven-plugin:0.40.2:build failed: null value in entry: TEST=null

Caused by: java.lang.NullPointerException: null value in entry: TEST=null
at com.google.common.collect.CollectPreconditions.checkEntryNotNull (CollectPreconditions.java:32)
at com.google.common.collect.ImmutableMap.entryOf (ImmutableMap.java:172)
at com.google.common.collect.ImmutableMap$Builder.put (ImmutableMap.java:282)
at com.google.common.collect.ImmutableMap$Builder.put (ImmutableMap.java:296)
at com.google.common.collect.ImmutableMap$Builder.putAll (ImmutableMap.java:324)
at com.google.common.collect.ImmutableMap$Builder.putAll (ImmutableMap.java:307)
at io.fabric8.maven.docker.service.BuildService.prepareBuildArgs (BuildService.java:210)
at io.fabric8.maven.docker.service.BuildService.buildImage (BuildService.java:171)
at io.fabric8.maven.docker.service.BuildService.buildImage (BuildService.java:71)
at io.fabric8.maven.docker.BuildMojo.proceedWithDockerBuild (BuildMojo.java:108)
at io.fabric8.maven.docker.BuildMojo.proceedWithBuildProcess (BuildMojo.java:91)
at io.fabric8.maven.docker.BuildMojo.buildAndTag (BuildMojo.java:84)

@rohanKanojia
Copy link
Member

@flocard02 : Could you please create a new issue for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants