fortinetdev / terraform-provider-fortimanager

Mozilla Public License 2.0
10 stars 9 forks source link

JSON API access level "None" crashes plugin #26

Open seculonia-jk opened 1 year ago

seculonia-jk commented 1 year ago

Hi,

while setting up an integration with a fresh FortiManager the plugin crashed repeatedly. It turned out that the root cause was that the plugin's account was not configured for JSON API access. You'll find a stack trace below - a more explicit way of surfacing this configuration error would be good to have.

Best regards Jens Krewald

Stack trace from the terraform-provider-fortimanager_v1.6.0 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 59 [running]:
github.com/fortinetdev/forti-sdk-go/fortimanager2/sdkcore.(*FortiSDKClient).GetDeviceVersion(0xc000f8c640, 0x0, 0x1bb5eb0, 0x2, 0x252cae0)
        github.com/fortinetdev/forti-sdk-go@v1.9.1/fortimanager2/sdkcore/forticlient.go:212 +0xca5
github.com/terraform-providers/terraform-provider-fortimanager/fmg.resourceDvmCmdAddDeviceUpdate(0xc0001c3800, 0x1a70c40, 0xc000f53920, 0x0, 0x0)
        github.com/terraform-providers/terraform-provider-fortimanager/fmg/resource_dvm_cmd_add_device.go:158 +0xbb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc000298a80, 0x1df4f60, 0xc000f7f2c0, 0xc0001c3800, 0x1a70c40, 0xc000f53920, 0x0, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.19.0/helper/schema/resource.go:695 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000298a80, 0x1df4f60, 0xc000f7f2c0, 0xc00083d520, 0xc0001c3600, 0x1a70c40, 0xc000f53920, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.19.0/helper/schema/resource.go:837 +0x79d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00079c078, 0x1df4f60, 0xc000f7f110, 0xc000f550e0, 0x1bd6d0e, 0x13, 0x1bb9ac2)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.19.0/helper/schema/grpc_provider.go:1021 +0xb4f
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0000a6280, 0x1df4f60, 0xc000f7f110, 0xc000f642a0, 0x0, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.12.0/tfprotov5/tf5server/server.go:813 +0x70c
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x1b7cee0, 0xc0000a6280, 0x1df4f60, 0xc000f7e630, 0xc000f64230, 0x0, 0x1df4f60, 0xc000f7e630, 0xc0000f0840, 0x2a6)
        github.com/hashicorp/terraform-plugin-go@v0.12.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000218380, 0x1dfc398, 0xc000624000, 0xc0002db320, 0xc0006b0120, 0x24eeb00, 0x0, 0x0, 0x0)
        google.golang.org/grpc@v1.48.0/server.go:1295 +0x693
google.golang.org/grpc.(*Server).handleStream(0xc000218380, 0x1dfc398, 0xc000624000, 0xc0002db320, 0x0)
        google.golang.org/grpc@v1.48.0/server.go:1636 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc00011e1b0, 0xc000218380, 0x1dfc398, 0xc000624000, 0xc0002db320)
        google.golang.org/grpc@v1.48.0/server.go:932 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.48.0/server.go:930 +0x1fd

Error: The terraform-provider-fortimanager_v1.6.0 plugin crashed!
lix-fortinet commented 1 year ago

Hi @seculonia-jk,

Thank you for raising this issue. Could we know your FortiManager version? So that we can debug it in our env.

Thanks, Xing

seculonia-jk commented 1 year ago

Hi,

according to my colleague who set it up, this was with 7.2.1 or thereabouts - a very recent one, freshly set up.

Best regards Jens Krewald