CheckPointSW / terraform-provider-checkpoint

Terraform provider for Check Point
https://www.terraform.io/docs/providers/checkpoint/
Mozilla Public License 2.0
28 stars 40 forks source link

Crash due to package import #112

Closed zjaniga closed 2 years ago

zjaniga commented 2 years ago

Hi,

Getting the below error when importing package, is this a known bug?

Switched to workspace "lab".
module.package.checkpoint_management_package.imported_package[0]: Importing from ID "4dc49793-2aeb-4dc2-9fa9-86814d43d5ac"...
module.package.checkpoint_management_package.imported_package[0]: Import prepared!
  Prepared checkpoint_management_package for import
module.package.checkpoint_management_package.imported_package[0]: Refreshing state... [id=4dc49793-2aeb-4dc2-9fa9-86814d43d5ac]
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
│ details.
╵

Stack trace from the terraform-provider-checkpoint_v1.7.0 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 39 [running]:
github.com/CheckPointSW/terraform-provider-checkpoint/checkpoint.readManagementPackage(0xc0007d5730, 0x13d97c0, 0xc000164000, 0xc0007d5730, 0x0)
    github.com/CheckPointSW/terraform-provider-checkpoint/checkpoint/resource_checkpoint_management_package.go:217 +0x1150
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000499400, 0xc0007c9b30, 0x13d97c0, 0xc000164000, 0xc00000fc60, 0x0, 0x0)
    github.com/hashicorp/terraform-plugin-sdk@v1.17.0/helper/schema/resource.go:470 +0x119
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00000e740, 0x176efe0, 0xc0007e7ef0, 0xc0007c3560, 0xc00000e740, 0xc0007e7ef0, 0xc00058aba0)
    github.com/hashicorp/terraform-plugin-sdk@v1.17.0/internal/helper/plugin/grpc_provider.go:[53](https://github.com/ION-Analytics/network-tf-dev-cdflow2/runs/6623499245?check_suite_focus=true#step:3:54)5 +0x3d8
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x13bf740, 0xc00000e740, 0x176efe0, 0xc0007e7ef0, 0xc0007c3500, 0x0, 0x176efe0, 0xc0007e7ef0, 0xc00037e5a0, 0x113)
    github.com/hashicorp/terraform-plugin-sdk@v1.17.0/internal/tfplugin5/tfplugin5.pb.go:3269 +0x217
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00009fa40, 0x177bf00, 0xc0000a7980, 0xc000902500, 0xc000084cf0, 0x2037230, 0x0, 0x0, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1194 +0x50a
google.golang.org/grpc.(*Server).handleStream(0xc00009fa40, 0x177bf00, 0xc0000a7980, 0xc000902500, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1517 +0xcfd
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000102420, 0xc00009fa40, 0x177bf00, 0xc0000a7980, 0xc000902500)
    google.golang.org/grpc@v1.32.0/server.go:859 +0xa1
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.32.0/server.go:8[57](https://github.com/ION-Analytics/network-tf-dev-cdflow2/runs/6623499245?check_suite_focus=true#step:3:58) +0x204

Error: The terraform-provider-checkpoint_v1.7.0 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.

exec process exited with error status code 1
Error: Process completed with exit code 1.
zjaniga commented 2 years ago

Tested with 1.8, same error.

module.package.checkpoint_management_package.imported_package[0]: Importing from ID "4dc49793-2aeb-4dc2-9fa9-86814d43d5ac"...
module.package.checkpoint_management_package.imported_package[0]: Import prepared!
  Prepared checkpoint_management_package for import
module.package.checkpoint_management_package.imported_package[0]: Refreshing state... [id=4dc49793-2aeb-4dc2-9fa9-86814d43d5ac]
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
│ details.
╵

Stack trace from the terraform-provider-checkpoint_v1.8.0 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 21 [running]:
github.com/CheckPointSW/terraform-provider-checkpoint/checkpoint.readManagementPackage(0xc00018e5b0, 0x1268e00, 0xc0008b2540, 0xc00018e5b0, 0x0)
    github.com/CheckPointSW/terraform-provider-checkpoint/checkpoint/resource_checkpoint_management_package.go:217 +0x1173
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000121720, 0xc0007f43c0, 0x1268e00, 0xc0008b2540, 0xc000694a40, 0x0, 0x0)
    github.com/hashicorp/terraform-plugin-sdk@v1.17.0/helper/schema/resource.go:470 +0x12e
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc000694840, 0x14a0ab0, 0xc0007e82d0, 0xc000662360, 0xc000694840, 0xc0007e82d0, 0xc0000b8ba0)
    github.com/hashicorp/terraform-plugin-sdk@v1.17.0/internal/helper/plugin/grpc_provider.go:[53](https://github.com/ION-Analytics/network-tf-dev-cdflow2/runs/6625168477?check_suite_focus=true#step:3:54)5 +0x3dd
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x1252aa0, 0xc000694840, 0x14a0ab0, 0xc0007e82d0, 0xc000662300, 0x0, 0x14a0ab0, 0xc0007e82d0, 0xc000188240, 0x113)
    github.com/hashicorp/terraform-plugin-sdk@v1.17.0/internal/tfplugin5/tfplugin5.pb.go:3269 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00038ce00, 0x14a9ab8, 0xc00053[56](https://github.com/ION-Analytics/network-tf-dev-cdflow2/runs/6625168477?check_suite_focus=true#step:3:57)80, 0xc0007fc000, 0xc00048f4a0, 0x1a887f0, 0x0, 0x0, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc00038ce00, 0x14a9ab8, 0xc000535680, 0xc0007fc000, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0002b2350, 0xc00038ce00, 0x14a9ab8, 0xc000535680, 0xc0007fc000)
    google.golang.org/grpc@v1.32.0/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.32.0/server.go:8[57](https://github.com/ION-Analytics/network-tf-dev-cdflow2/runs/6625168477?check_suite_focus=true#step:3:58) +0x1fd

Error: The terraform-provider-checkpoint_v1.8.0 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.

exec process exited with error status code 1
Error: Process completed with exit code 1.
chkp-royl commented 2 years ago

Hi @zjaniga , Thanks for your feedback. We will fix this bug soon in the next version of terraform provider.

Regards, Roy

chkp-royl commented 2 years ago

Fixed in version 1.9.0. Please try to re-import and let us know if you have any issues.

zjaniga commented 2 years ago

I can confirm it is working now. Thank you!