You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
% terraform version
Terraform v1.6.2
on linux_amd64
Terraform Configuration Files
locals {
2023_test = "foobar"
}
Debug Output
(Ignoring the request to use a Gist instead of pasting here because the testcase is so trivial that the debug output isn't actually that long.)
% TF_LOG=trace terraform plan
2023-10-26T20:25:19.051-0500 [INFO] Terraform version: 1.6.2
2023-10-26T20:25:19.051-0500 [DEBUG] using github.com/hashicorp/go-tfe v1.36.0
2023-10-26T20:25:19.051-0500 [DEBUG] using github.com/hashicorp/hcl/v2 v2.19.1
2023-10-26T20:25:19.051-0500 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2023-10-26T20:25:19.051-0500 [DEBUG] using github.com/zclconf/go-cty v1.14.1
2023-10-26T20:25:19.051-0500 [INFO] Go runtime version: go1.21.1
2023-10-26T20:25:19.051-0500 [INFO] CLI args: []string{"terraform", "plan"}
2023-10-26T20:25:19.051-0500 [TRACE] Stdout is a terminal of width 80
2023-10-26T20:25:19.051-0500 [TRACE] Stderr is a terminal of width 80
2023-10-26T20:25:19.051-0500 [TRACE] Stdin is a terminal
2023-10-26T20:25:19.051-0500 [DEBUG] Attempting to open CLI config file: /var/home/alex/.terraformrc
2023-10-26T20:25:19.051-0500 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2023-10-26T20:25:19.051-0500 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2023-10-26T20:25:19.051-0500 [DEBUG] ignoring non-existing provider search directory /var/home/alex/.terraform.d/plugins
2023-10-26T20:25:19.051-0500 [DEBUG] ignoring non-existing provider search directory /var/home/alex/.local/share/terraform/plugins
2023-10-26T20:25:19.051-0500 [DEBUG] ignoring non-existing provider search directory /var/home/alex/.local/share/flatpak/exports/share/terraform/plugins
2023-10-26T20:25:19.051-0500 [DEBUG] ignoring non-existing provider search directory /var/lib/flatpak/exports/share/terraform/plugins
2023-10-26T20:25:19.051-0500 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2023-10-26T20:25:19.051-0500 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2023-10-26T20:25:19.052-0500 [INFO] CLI command args: []string{"plan"}
╷
│ Error: Argument or block definition required
│
│ on test.tf line 2, in locals:
│ 2: 2023_test = "foobar"
│
│ An argument or block definition is required here.
╵
Expected Behavior
I should have seen something similar to this error:
╷
│ Error: Invalid resource name
│
│ on dns.tf line 209, in resource "aws_route53_record" "2023-ephemeral-delegation-a":
│ 209: resource "aws_route53_record" "2023-ephemeral-delegation-a" {
│
│ A name must start with a letter or underscore and may contain only letters, digits, underscores, and dashes.
╵
Actual Behavior
I saw an error about an argument or block definition being required, even though AFAICT that was provided.
Steps to Reproduce
Create test.tf with the repro file contents
terraform plan
Additional Context
No response
References
No response
The text was updated successfully, but these errors were encountered:
In this situation Terraform is encountering a number and noticing that a number cannot possibly be the start of "an argument or block definition". Unfortunately with syntax errors Terraform often has to do the best it can with partial information, because before there's even a complete parse tree any assumptions Terraform is making about context are only guesses.
With that said, given that a number is never valid in this particular context I imagine it would be possible to add a special case to the parser for when it encounters a number here. I don't think it would be appropriate to use an error exactly like the other one you shared about resource names -- Terraform is far more certain that the string there is intended to be a resource name, because main parsing was already complete -- but we could perhaps compromise by adding an extra sentence to the detail part of the error message:
╷
│ Error: Argument or block definition required
│
│ on test.tf line 2, in locals:
│ 2: 2023_test = "foobar"
│
│ An argument or block definition is required here. Argument names and
│ block types cannot begin with a digit.
╵
Thanks for reporting this! The code that's handling this actually lives upstream in the HCL repository, so I'm going to label this as "upstream" but I think we should still use this issue to represent the problem since it's most likely to be the Terraform team working on this change.
Terraform Version
Terraform Configuration Files
Debug Output
(Ignoring the request to use a Gist instead of pasting here because the testcase is so trivial that the debug output isn't actually that long.)
Expected Behavior
I should have seen something similar to this error:
Actual Behavior
I saw an error about an argument or block definition being required, even though AFAICT that was provided.
Steps to Reproduce
test.tf
with the repro file contentsterraform plan
Additional Context
No response
References
No response
The text was updated successfully, but these errors were encountered: