jfrog/terraform-provider-xray

xray_ignore_rule errors out on apply

tkorrapati1 opened this issue · 1 comments

Describe the bug
TF resource xray_ignore_rule fails on apply

Requirements for and issue

  • Artifactory version
{
  "version" : "7.43.1",
  "revision" : "74301900",
  "addons" : [ "aol", "ha", "build", "docker", "vagrant", "replication", "filestore", "plugins", "gems", "composer", "npm", "bower", "git-lfs", "nuget", "debian", "opkg", "rpm", "cocoapods", "conan", "vcs", "pypi", "release-bundle", "jf-connect", "jf-event", "replicator", "keys", "alpine", "cargo", "chef", "federated", "git", "observability", "pub", "rest", "swift", "conda", "terraform", "tracker", "license", "puppet", "ldap", "sso", "layouts", "properties", "search", "securityresourceaddon", "filtered-resources", "p2", "watch", "webstart", "support", "xray", "retention" ],
  "license" : "5f9df6071ac09d605be66ff4193b62e06cdb28b04",
  "entitlements" : {
    "EVENT_BASED_PULL_REPLICATION" : true,
    "SMART_REMOTE_TARGET_FOR_EDGE" : false,
    "REPO_REPLICATION" : true,
    "MULTIPUSH_REPLICATION" : true
  }
}
  • Xray Version
{"xray_version":"3.59.4","xray_revision":"c932c00"}

  • Terraform Version
 1.3.6.
  • Relevant Terraform Code - Very Minimal
resource "xray_ignore_rule" "this" {
  notes        = var.notes
  cves         = var.cves
  watches      = var.watches
}

  • Terraform Plan/apply Output + Error
$ terraform apply 
Acquiring state lock. This may take a few moments...
data.vault_generic_secret.tf_af_rw_user: Reading...
data.vault_generic_secret.tf_af_rw_user: Read complete after 0s [id=secret/common/artifactory_saas/automation/tf-af-rw-user]
module.xray_security_policy_image_promotion.xray_security_policy.this: Refreshing state... [id=tf-policy-image-promotion]
module.xray_security_watch_image_promotion.xray_watch.this: Refreshing state... [id=tf-watch-image-promotion]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.xray_ignore_rule.xray_ignore_rule.this will be created
  + resource "xray_ignore_rule" "this" {
      + author           = (known after apply)
      + created          = (known after apply)
      + cves             = [
          + "CVE-2021-43616",
        ]
      + docker_layers    = (known after apply)
      + id               = (known after apply)
      + is_expired       = (known after apply)
      + licenses         = (known after apply)
      + notes            = "Ignore rule"
      + operational_risk = (known after apply)
      + policies         = (known after apply)
      + vulnerabilities  = (known after apply)
      + watches          = [
          + "tf-watch-image-promotion",
        ]

      + artifact {
          + name    = (known after apply)
          + path    = (known after apply)
          + version = (known after apply)
        }

      + build {
          + name    = (known after apply)
          + version = (known after apply)
        }

      + component {
          + name    = (known after apply)
          + version = (known after apply)
        }

      + release_bundle {
          + name    = (known after apply)
          + version = (known after apply)
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions in workspace "shared"?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.xray_ignore_rule.xray_ignore_rule.this: Creating...
╷
│ Error: Plugin did not respond
│ 
│   with module.xray_ignore_rule.xray_ignore_rule.this,
│   on ../modules/ignore-rules/main.tf line 14, in resource "xray_ignore_rule" "this":
│   14: resource "xray_ignore_rule" "this" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵
Releasing state lock. This may take a few moments...

Stack trace from the terraform-provider-xray_v1.9.4 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1050a6650]

goroutine 53 [running]:
github.com/jfrog/terraform-provider-xray/pkg/xray.resourceXrayIgnoreRule.func3({{0x1400003c420, 0x24}, {0x0, 0x0}, {0x1400003a1c0, 0xd}, 0x1400000c150, 0x0, {0x1400003a1d0, 0xb}, ...}, ...)
        github.com/jfrog/terraform-provider-xray/pkg/xray/resource_xray_ignore_rule.go:312 +0x2a0
github.com/jfrog/terraform-provider-xray/pkg/xray.resourceXrayIgnoreRule.func7({0x105360d50, 0x140001704e0}, 0x140004b8300, {0x105350620?, 0x140005ca1e0})
        github.com/jfrog/terraform-provider-xray/pkg/xray/resource_xray_ignore_rule.go:455 +0x4f8
github.com/jfrog/terraform-provider-xray/pkg/xray.resourceXrayIgnoreRule.func8({0x105360d50, 0x140001704e0}, 0x1400055cef8?, {0x105350620?, 0x140005ca1e0?})
        github.com/jfrog/terraform-provider-xray/pkg/xray/resource_xray_ignore_rule.go:494 +0x2e8
github.com/jfrog/terraform-provider-shared/util.applyTelemetry.func1({0x105360d50?, 0x140001704e0}, 0x0?, {0x105350620?, 0x140005ca1e0})
        github.com/jfrog/terraform-provider-shared@v1.7.0/util/util.go:225 +0x1d4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x140002afea0, {0x105360d88, 0x140004ac270}, 0xd?, {0x105350620, 0x140005ca1e0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.14.0/helper/schema/resource.go:707 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x140002afea0, {0x105360d88, 0x140004ac270}, 0x1400013ab60, 0x140004b8200, {0x105350620, 0x140005ca1e0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.14.0/helper/schema/resource.go:837 +0x874
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x140003fe5a0, {0x105360ce0?, 0x1400010f9c0?}, 0x14000537540)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.14.0/helper/schema/grpc_provider.go:1021 +0xb94
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x14000399720, {0x105360d88?, 0x14000565a70?}, 0x14000542af0)
        github.com/hashicorp/terraform-plugin-go@v0.9.0/tfprotov5/tf5server/server.go:812 +0x38c
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x10532c360?, 0x14000399720}, {0x105360d88, 0x14000565a70}, 0x140001712c0, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.9.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400027c8c0, {0x105363728, 0x140001024e0}, 0x14000575e60, 0x14000413b30, 0x1057da8e0, 0x0)
        google.golang.org/grpc@v1.45.0/server.go:1282 +0xb3c
google.golang.org/grpc.(*Server).handleStream(0x1400027c8c0, {0x105363728, 0x140001024e0}, 0x14000575e60, 0x0)
        google.golang.org/grpc@v1.45.0/server.go:1619 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.45.0/server.go:921 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.45.0/server.go:919 +0x298

Error: The terraform-provider-xray_v1.9.4 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.

Expected behavior
Expected Ignore rule to be created, but fails with above error.

@tkorrapati1, thanks for the ticket! It's fixed in v1.9.7