Skip to content

tencentcloud_teo_rule_engine: panic on apply when rules block contains empty actions {} #4217

Description

@RezaPurut

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v1.9.x

  • provider registry.terraform.io/tencentcloudstack/tencentcloud v1.82.101

Also reproduced on provider v1.82.90.

Affected Resource(s)

  • tencentcloud_teo_rule_engine

Terraform Configuration Files

# Inside tencentcloud_teo_rule_engine resource, sub_rules block:
dynamic "rules" {
  for_each = var.override_authorization_header ? [1] : []
  content {
    or {
      and {
        operator    = "equal"
        target      = "host"
        ignore_case = true
        values      = [local.domain_names]
      }
      and {
        operator = "notequal"
        target   = "url"
        values   = ["/api-gateway/*"]
      }
    }
    actions {
      rewrite_action {
        action = "RequestHeader"
        parameters {
          action = "del"
          name   = "authorization"
          values = []
        }
      }
    }
    actions {
      # Empty actions block - causes crash during apply
    }
  }
}

Debug Output

I'm not comfortable pasting sensitive debug output anywhere at this point.

Panic Output

  Stack trace from the terraform-provider-tencentcloud_v1.82.90 plugin:
  
  panic: interface conversion: interface {} is nil, not map[string]interface {}
  
  goroutine 61 [running]:
  github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/teo.resourceTencentCloudTeoRuleEngineUpdate(0xc0023da380, {0x7cfe6a0?, 0xc0005d03b0})
      github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/teo/resource_tc_teo_rule_engine.go:1368 +0x25fd
  github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xa495048?, {0xa495048?, 0xc00426f530?}, 0xd?, {0x7cfe6a0?, 0xc0005d03b0?})
      github.com/hashicorp/terraform-plugin-sdk/v2@v2.20.0/helper/schema/resource.go:729 +0x178
  github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00167c460, {0xa495048, 0xc00426f530}, 0xc0021d3d40, 0xc0023db680, {0x7cfe6a0, 0xc0005d03b0})
      github.com/hashicorp/terraform-plugin-sdk/v2@v2.20.0/helper/schema/resource.go:847 +0x82c
  github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00000c540, {0xa495048?, 0xc00426f410?}, 0xc00341abe0)
      github.com/hashicorp/terraform-plugin-sdk/v2@v2.20.0/helper/schema/grpc_provider.go:1021 +0xe3c
  github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0004d00a0, {0xa495048?, 0xc00426ede0?}, 0xc0003e8770)
      github.com/hashicorp/terraform-plugin-go@v0.12.0/tfprotov5/tf5server/server.go:813 +0x4fc
  github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x87a5100?, 0xc0004d00a0}, {0xa495048, 0xc00426ede0}, 0xc0003e8700, 0x0)
      github.com/hashicorp/terraform-plugin-go@v0.12.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
  google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000001e0, {0xa498f50, 0xc000a641a0}, 0xc004267320, 0xc001aae450, 0x1347e0a0, 0x0)
      google.golang.org/grpc@v1.53.0/server.go:1336 +0xd13
  google.golang.org/grpc.(*Server).handleStream(0xc0000001e0, {0xa498f50, 0xc000a641a0}, 0xc004267320, 0x0)
      google.golang.org/grpc@v1.53.0/server.go:1704 +0xa1b
  google.golang.org/grpc.(*Server).serveStreams.func1.2()
      google.golang.org/grpc@v1.53.0/server.go:965 +0x98
  created by google.golang.org/grpc.(*Server).serveStreams.func1
      google.golang.org/grpc@v1.53.0/server.go:963 +0x28a
  
  Error: The terraform-provider-tencentcloud_v1.82.90 plugin crashed!
  
  This is always indicative of a bug within the plugin. It would be immensely
  helpful if you could report the crash with the plugin's maintainers so that it
  can be fixed. The output above should help diagnose the issue.
  
  
  exit status 1

Expected Behavior

The provider should update the tencentcloud_teo_rule_engine resource successfully when restructuring actions and sub_rules blocks, handling nil/empty action maps gracefully.

Actual Behavior

The provider panics with interface conversion: interface {} is nil, not map[string]interface {} at resource_tc_teo_rule_engine.go:1368 during the update operation. The crash occurs when the plan includes sub_rules with empty or restructured action blocks.

Steps to Reproduce

  1. Have a tencentcloud_teo_rule_engine resource where any rules block contains an empty actions {} (no normal_action, rewrite_action, or code_action inside)
  2. Run terraform apply

Important Factoids

  1. the bug persists across versions.

References

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions