Skip to content

PDS Job parameter with unset values lead to exception #4209

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

Open
de-jcup opened this issue May 28, 2025 · 0 comments · May be fixed by #4211
Open

PDS Job parameter with unset values lead to exception #4209

de-jcup opened this issue May 28, 2025 · 0 comments · May be fixed by #4211

Comments

@de-jcup
Copy link
Member

de-jcup commented May 28, 2025

Situation

If we have a PDS job parameter which is defined this way:

test.key=env:YOUR_VARIABLE

It can happen that the environment variable (on SecHub Server) is not defined/not set.

In this case following exception is thrown:

java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "<parameter1>" is null
	at java.base/java.lang.ProcessEnvironment.validateValue(Unknown Source)
	at java.base/java.lang.ProcessEnvironment$Value.valueOf(Unknown Source)
	at java.base/java.lang.ProcessEnvironment$StringEnvironment.put(Unknown Source)
	at java.base/java.lang.ProcessEnvironment$StringEnvironment.put(Unknown Source)
	at com.mercedesbenz.sechub.pds.execution.PDSExecutionEnvironmentService.addJobParamDataWhenAccepted(PDSExecutionEnvironmentService.java:217)
	at com.mercedesbenz.sechub.pds.execution.PDSExecutionEnvironmentService.addPdsExecutorJobParameters(PDSExecutionEnvironmentService.java:129)
	at com.mercedesbenz.sechub.pds.execution.PDSExecutionEnvironmentService.calculateAndSetupEnvironment(PDSExecutionEnvironmentService.java:76)
	at com.mercedesbenz.sechub.pds.execution.PDSExecutionEnvironmentService.initProcessBuilderEnvironmentMap(PDSExecutionEnvironmentService.java:67)
	at com.mercedesbenz.sechub.pds.execution.PDSExecutionCallable.createProcess(PDSExecutionCallable.java:481)
	at com.mercedesbenz.sechub.pds.execution.PDSExecutionCallable.call(PDSExecutionCallable.java:125)
	at com.mercedesbenz.sechub.pds.execution.PDSExecutionCallable.call(PDSExecutionCallable.java:53)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

Analyze

The problem is, that the environment map for process is not able to handle null values (empty strings are okay, but not null).
If a key is not null but the value is null the exception will occur.

Wanted

  • If a key is null it shall be ignored
  • if a value is null a warning shall be logged about missing value for the key and it shall be skipped.
de-jcup added a commit that referenced this issue May 28, 2025
- the new environment access handles null keys and null values and
  skips put operation in these cases + does log warnings
- improved PDSKeyToEnvConverter + existing test
@de-jcup de-jcup linked a pull request May 28, 2025 that will close this issue
de-jcup added a commit that referenced this issue May 28, 2025
- the new environment access handles null keys and null values and
  skips put operation in these cases + does log warnings
- improved PDSKeyToEnvConverter + existing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant