Loading...
Loading...
### Terraform Version ```shell Terraform v1.6.0 on linux_amd64 provider registry.terraform.io/hashicorp/aws v6.20.0 ``` ### Terraform Configuration Files terraform { required_version = ">= 1.6.0" required_providers { aws = { source = "hashicorp/aws" version = ">= 6.0.0" } } } provider "aws" { region = "us-east-1" } variable "use_default_bus" { type = bool default = true } # When true, data exists and resource count = 0 data "aws_cloudwatch_event_bus" "default" { count = var.use_default_bus ? 1 : 0 name = "default" } # When true, this resource does not exist (count = 0) resource "aws_cloudwatch_event_bus" "this" { count = var.use_default_bus ? 0 : 1 name = "example-bus" } locals { # Conditional references a possibly-nonexistent resource index on the else branch. # On Terraform 1.6.0 this can crash validate with cty marks error. event_bus_arn = var.use_default_bus ? data.aws_cloudwatch_event_bus.default[0].arn : aws_cloudwatch_event_bus.this[0].arn } output "event_bus_arn" { value = local.event_bus_arn } ### Debug Output !!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!! value is marked, so must be unmarked first github.com/zclconf/go-cty/cty.Value.assertUnmarked(...) github.com/zclconf/go-cty/cty.Value.AsString(...) github.com/zclconf/go-cty/cty.Value.Range(...) github.com/hashicorp/hcl/v2/hclsyntax.(*ConditionalExpr).Value(...) github.com/hashicorp/terraform/internal/terraform.(*NodeValidatableResource).validateResource(...) ### Expected Behavior terraform validate should succeed or return a normal diagnostic; it should not crash. ### Actual Behavior terraform validate crashes with: “value is marked, so must be unmarked first” Stack trace shows hclsyntax.(*ConditionalExpr).Value and cty marks. ### Steps to Reproduce Save the configuration above as main.tf. Run: terraform init -input=false -upgrade terraform validate Crash reproduces consistently on Terraform 1.6.0. ### Additional Context Environment: CI runner (Ubuntu), Terraform 1.6.0, aws provider v6.20.0. The crash appears tied to a conditional expression that selects between a data source and a resource whose count = 0, referencing aws_cloudwatch_event_bus.this[0].arn on the else branch. Although conditionals should short-circuit, evaluating branch metadata seems to propagate cty marks and triggers the panic. ### References N/A (could not find an existing issue specifically for this exact crash; it resembles prior cty marks/conditional evaluation bugs) ### Generative AI / LLM assisted development? Cursor - ChatGPT-5
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.