Skip to content

Commit

Permalink
hcl2: don't show an empty source on var errors
Browse files Browse the repository at this point in the history
If a variable is defined and overriden in the packer command-line, but
there's a problem during the evaluation of this override (type error
typically), we show an error message which details the problem.

This message points to a temporary in-memory HCL2 "file" that we use for
parsing and evaluating the expression for the variable, but since it's
virtual, there's no point in using this as the source for the error, as
it will always yield "line 0" and no contents.

So, in order to limit confusion here, we remove the source for this
error message.
  • Loading branch information
lbajolet-hashicorp committed Nov 27, 2023
1 parent 17ff508 commit bb26771
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion hcl2template/types.variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ func (cfg *PackerConfig) collectInputVariableValues(env []string, files []*hcl.F
Severity: hcl.DiagError,
Summary: "Invalid argument value for -var variable",
Detail: fmt.Sprintf("The received arg value for %s is not compatible with the variable's type constraint: %s.", name, err),
Subject: expr.Range().Ptr(),
})
val = cty.DynamicVal
}
Expand Down

0 comments on commit bb26771

Please sign in to comment.