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

And chaining operation not end evaluation early #35722

Closed
NewbMiao opened this issue Sep 13, 2024 · 1 comment
Closed

And chaining operation not end evaluation early #35722

NewbMiao opened this issue Sep 13, 2024 · 1 comment
Labels
bug duplicate issue closed because another issue already tracks this problem

Comments

@NewbMiao
Copy link

Terraform Version

1.9.3

Terraform Configuration Files

variable "testObj" {
  type = object({
    name = optional(string, "")
  })
  default = null
}
output "name" {
  value = var.testObj != null && var.testObj.name != null ? var.test.name : "empty"
}

Debug Output

https://gist.github.com/NewbMiao/b3a2677d3507b62f5f05be71d3a19560

Expected Behavior

var.testObj != null && var.testObj.name != null should end evaluation early in var.testObj != null since it's already false and no need to check the following operation.

Actual Behavior

all operation evaluated even it can be end early

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Attempt to get attribute from null value
│ 
│   on main.tf line 8, in output "name":
│    8:   value = var.testObj != null && var.testObj.name != null ? var.testObj.name : "empty"
│     ├────────────────
│     │ var.testObj is null
│ 
│ This value is null, so it does not have any attributes.

Steps to Reproduce

  1. terraform init
  2. terraform plan

Additional Context

No response

References

No response

@NewbMiao NewbMiao added bug new new issue not yet triaged labels Sep 13, 2024
@jbardin
Copy link
Member

jbardin commented Sep 13, 2024

Duplicate of #24128

@jbardin jbardin marked this as a duplicate of #24128 Sep 13, 2024
@jbardin jbardin closed this as completed Sep 13, 2024
@crw crw added duplicate issue closed because another issue already tracks this problem and removed new new issue not yet triaged labels Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug duplicate issue closed because another issue already tracks this problem
Projects
None yet
Development

No branches or pull requests

3 participants