-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Panic from invalid CLI -var if a valid variable is referenced in env{} #10043
Comments
Thanks for opening this @gulducat! You're right that the crash is entirely constrained to the CLI; all the HCL2 parsing happens there and the server just gets the "rendered" JSON API body. But we definitely should fix this! |
Hi @gulducat I did some quick reproduction work and I don't think the error here is actually because of the extra variable ( If we use the following jobspec: variable "one" {
type = string
}
job "bug" {
task "bug" {
env {
ONE = var.one
}
}
} Then we get the following validation errors:
LOL on this error message though (copy and pasted from packer 😊 ):
Same results with the following jobspec: variables {
one = "foo"
}
job "bug" {
task "bug" {
env {
ONE = var.one
}
}
} Which implicitly declares the type. The docs say:
So that definitely could use some improvement. And in any case, we shouldn't be panicking. |
I've got a fix in #10045. The bug was sort of interesting: we were catching the error during validation but then merrily continuing on with the invalid state to decode the job, which panicked and obscured the error message. That patch will ship in 1.0.4 |
Huzzah! I was hoping this would be a pretty easy one, thanks for the extra info and the fix @tgross! |
I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues. |
Nomad version
Nomad v1.0.3 (08741d9f2003ec26e44c72a2c0e27cdf0eadb6ee)
Operating system and Environment details
macOS Catalina, but I suspect this is not os-specific.
Issue
Normally when providing an invalid variable name with
nomad run -var='somevar=someval'
,it will output a mostly sensible error saying the variable is invalid.
In this case it panics with "invalid memory address or nil pointer dereference"
It seems to be on the cli side, a server/agent doesn't even need to be running.
I am not sure if this can occur in other jobspec contexts; I ran across it in
env{}
Reproduction steps
Run this with the below jobspec, named
bug.nomad
here.nomad run -var='invalid=yes' bug.nomad
or any variable name aside from the valid "one".
Job file
Error output
The text was updated successfully, but these errors were encountered: