diff --git a/configs/test-fixtures/invalid-files/provider-syntax.tf b/configs/test-fixtures/invalid-files/provider-syntax.tf new file mode 100644 index 000000000..7cf680fee --- /dev/null +++ b/configs/test-fixtures/invalid-files/provider-syntax.tf @@ -0,0 +1,3 @@ +provider "template" { + version = +} diff --git a/configs/version_constraint.go b/configs/version_constraint.go index 7aa19efc6..e40ce1639 100644 --- a/configs/version_constraint.go +++ b/configs/version_constraint.go @@ -45,6 +45,13 @@ func decodeVersionConstraint(attr *hcl.Attribute) (VersionConstraint, hcl.Diagno return ret, diags } + if !val.IsWhollyKnown() { + // If there is a syntax error, HCL sets the value of the given attribute + // to cty.DynamicVal. A diagnostic for the syntax error will already + // bubble up, so we will move forward gracefully here. + return ret, diags + } + constraintStr := val.AsString() constraints, err := version.NewConstraint(constraintStr) if err != nil {