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

Terraform 0.13 validate crashes on Custom Validation Rules when error_message contains an accent #25143

Closed
xsaamiir opened this issue Jun 5, 2020 · 2 comments · Fixed by #25144
Labels
confirmed a Terraform Core team member has reproduced this issue v0.13 Issues (primarily bugs) reported against v0.13 releases

Comments

@xsaamiir
Copy link
Contributor

xsaamiir commented Jun 5, 2020

Terraform Version

Terraform v0.13.0-beta1

Terraform Configuration Files

variable "email_address" {
  type    = string
  default = "Application <[email protected]>"
  validation {
    condition     = can(regex(".{4,20} <[email protected]>", var.email_address))
    error_message = "A sentence with an accent é."
  }
}

Debug Output

https://gist.github.com/sharkyze/b3db1dd702518f2ad7d067b1a469f3f8

Crash Output

https://gist.github.com/sharkyze/b3db1dd702518f2ad7d067b1a469f3f8

Expected Behavior

Not to crash

Actual Behavior

Terraform crashes

Steps to Reproduce

$ mkdir tf-crash && cd tf-crash
$ cat <<END >main.tf
variable "email_address" {
  type    = string
  default = "Application <[email protected]>"
  validation {
    condition     = can(regex(".{4,20} <[email protected]>", var.email_address))
    error_message = "A sentence with an accent é."
  }
}
END
$ terraform validate

Additional Context

References

The error comes from the following line due to the accent:

last := runes[len(s)-1]

I was able to fix this bug by making the following changes: https://github.com/hashicorp/terraform/compare/master...sharkyze:configs/fix-looksLikeSentences-index-out-of-range?expand=0.

I would be happy to send a PR if you are ok with the changes

@danieldreier danieldreier added confirmed a Terraform Core team member has reproduced this issue v0.13 Issues (primarily bugs) reported against v0.13 releases labels Jun 5, 2020
@danieldreier
Copy link
Contributor

Thanks @sharkyze! I really, really appreciate you testing out 0.13!

I have reproduced this issue on 0.13 beta 1.

@ghost
Copy link

ghost commented Jul 9, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Jul 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
confirmed a Terraform Core team member has reproduced this issue v0.13 Issues (primarily bugs) reported against v0.13 releases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants