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

IllegalArgumentException: key can't be empty when using Oh My Zsh #469

Open
sladek-jan opened this issue Jan 16, 2025 · 0 comments
Open

Comments

@sladek-jan
Copy link

sladek-jan commented Jan 16, 2025

Hi,

So I was just trying to get OSS Review Toolkit (which uses Hoplite under the hood) to run on my machine.

  • Java version: openjdk 21.0.5 2024-10-15
  • ORT version: 46.0.0
  • Hoplite version (included in ORT): 2.9.0

I'm using a Macbook Pro M1 Max.
When I executed the ort command in my terminal, I got this weird issue:

Exception in thread "main" java.lang.IllegalArgumentException: key can't be empty
	at java.base/java.lang.System.checkKey(System.java:1100)
	at java.base/java.lang.System.getProperty(System.java:963)
	at com.sksamuel.hoplite.preprocessor.EnvOrSystemPropertyPreprocessor$handle$value$1.invoke(EnvOrSystemPropertyPreprocessor.kt:33)
	at com.sksamuel.hoplite.preprocessor.EnvOrSystemPropertyPreprocessor$handle$value$1.invoke(EnvOrSystemPropertyPreprocessor.kt:25)
	at kotlin.text.Regex.replace(Regex.kt:194)
	at com.sksamuel.hoplite.preprocessor.EnvOrSystemPropertyPreprocessor.handle(EnvOrSystemPropertyPreprocessor.kt:25)
	at com.sksamuel.hoplite.preprocessor.TraversingPrimitivePreprocessor.process(Preprocessor.kt:56)
	at com.sksamuel.hoplite.preprocessor.TraversingPrimitivePreprocessor.process(Preprocessor.kt:42)
	at com.sksamuel.hoplite.internal.Preprocessing.process(Preprocessing.kt:29)
	at com.sksamuel.hoplite.internal.Preprocessing.iterate(Preprocessing.kt:25)
	at com.sksamuel.hoplite.internal.Preprocessing.preprocess(Preprocessing.kt:21)
	at com.sksamuel.hoplite.internal.ConfigParser.loadResultAndContext(ConfigParser.kt:119)
	at com.sksamuel.hoplite.internal.ConfigParser.<init>(ConfigParser.kt:66)
	at com.sksamuel.hoplite.ConfigLoader.createConfigParser(ConfigLoader.kt:279)
	at com.sksamuel.hoplite.ConfigLoader.loadConfig(ConfigLoader.kt:226)
	at com.sksamuel.hoplite.ConfigLoader.loadConfig$default(ConfigLoader.kt:218)
	at org.ossreviewtoolkit.model.config.OrtConfiguration$Companion.load(OrtConfiguration.kt:211)
	at org.ossreviewtoolkit.model.config.OrtConfiguration$Companion.load$default(OrtConfiguration.kt:156)
	at org.ossreviewtoolkit.cli.OrtMain.run(OrtMain.kt:158)
	at com.github.ajalt.clikt.core.CoreCliktCommandKt.parse(CoreCliktCommand.kt:107)
	at com.github.ajalt.clikt.core.CoreCliktCommandKt.main(CoreCliktCommand.kt:78)
	at com.github.ajalt.clikt.core.CoreCliktCommandKt.main(CoreCliktCommand.kt:90)
	at org.ossreviewtoolkit.cli.OrtMainKt.main(OrtMain.kt:91)

After several hours of debugging, I found out that the culprit is this line if my .zshrc file:
source $ZSH/oh-my-zsh.sh.
When I commented it out, ORT ran normally.

Apparently, Oh My Zsh sets some system variables there and one of them turns out to be empty, which causes this line to call System.getProperty with an empty string, which in turn triggers that IllegalArgumentException.

Can you please look into this and maybe make that code more robust against such cases? Oh My Zsh is quite popular, so I might not be the only one running into that problem, and it's quite tricky to find out the cause.

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

No branches or pull requests

1 participant