hashicorp / terraform-provider-azuread

Terraform provider for Azure Active Directory
https://registry.terraform.io/providers/hashicorp/azuread/latest/docs
Mozilla Public License 2.0
415 stars 280 forks source link

terraform-provider-azuread_v2.50.0_x5.exe plugin: panic: runtime error: invalid memory address or nil pointer dereference #1399

Open hales8181 opened 1 month ago

hales8181 commented 1 month ago

When replacing a azuread_privileged_access_group_eligibility_schedule the plug in crashes when trying to destroy an existing eligbility schedule, and then subsequently continues on, tries to add the schedule but fails due to the role assigniment already existing.

╷ │ Error: Plugin did not respond │ │ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details. ╵ ╷ │ Error: Plugin did not respond │ │ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details. ╵ ╷ │ Error: Could not create assignment schedule request, PrivilegedAccessGroupEligibilityScheduleRequestsClient.BaseClient.Post(): unexpected status 400 with OData error: RoleAssignmentExists: The Role assignment already exists. │

Stack trace:

`Stack trace from the terraform-provider-azuread_v2.50.0_x5.exe plugin:

panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x40 pc=0xf1d6cd]

goroutine 98 [running]: github.com/manicminer/hamilton/msgraph.(PrivilegedAccessGroupEligibilityScheduleRequestsClient).Create(0xc00021e070, {0x1430a90, 0xc000210070}, {0xc0003e1080, {0xc000782110, 0x6}, {0x12aeefc, 0xb}, 0x0, 0x0, ...}) github.com/manicminer/hamilton@v0.68.0/msgraph/privilegedaccess_groups_eligibilityschedule_request.go:74 +0x32d github.com/hashicorp/terraform-provider-azuread/internal/services/identitygovernance.revokeEligibilityRequest({0x1430a90, 0xc000210070}, {0xc0003bc900, {0x14309b0, 0xc0003baba0}, 0xc00098e180, 0x0, {0x1430c50, 0x1acf5c0}}, 0xc00021e070, ...) github.com/hashicorp/terraform-provider-azuread/internal/services/identitygovernance/privileged_access_group_eligiblity_schedule_resource.go:294 +0x1d0 github.com/hashicorp/terraform-provider-azuread/internal/services/identitygovernance.(PrivilegedAccessGroupEligibilityScheduleResource).Delete.PrivilegedAccessGroupEligibilityScheduleResource.Delete.func1({0x1430a90, 0xc000210070}, {0xc0003bc900, {0x14309b0, 0xc0003baba0}, 0xc00098e180, 0x0, {0x1430c50, 0x1acf5c0}}) github.com/hashicorp/terraform-provider-azuread/internal/services/identitygovernance/privileged_access_group_eligiblity_schedule_resource.go:271 +0x315 github.com/hashicorp/terraform-provider-azuread/internal/sdk.(ResourceWrapper).Resource.func4({0x1430a90, 0xc000210070}, 0x0?, {0x117da40?, 0xc0003bc900?}) github.com/hashicorp/terraform-provider-azuread/internal/sdk/wrapper_resource.go:72 +0x147 github.com/hashicorp/terraform-provider-azuread/internal/sdk.(ResourceWrapper).Resource.(ResourceWrapper).diagnosticsWrapper.diagnosticsWrapper.func12({0x1430a90?, 0xc000210070?}, 0x0?, {0x117da40?, 0xc0003bc900?}) github.com/hashicorp/terraform-provider-azuread/internal/sdk/wrapper_resource.go:190 +0x59 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).delete(0xc0003d5500, {0x14309e8, 0xc000458b10}, 0xd?, {0x117da40, 0xc0003bc900}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:829 +0x11b github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).Apply(0xc0003d5500, {0x14309e8, 0xc000458b10}, 0xc0004c71e0, 0xc00098e100, {0x117da40, 0xc0003bc900}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:878 +0x605 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ApplyResourceChange(0xc000522048, {0x14309e8?, 0xc000458a20?}, 0xc000786140) github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xdbc github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(server).ApplyResourceChange(0xc00054a000, {0x14309e8?, 0xc000458180?}, 0xc000258070) github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:859 +0x56a github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1275860?, 0xc00054a000}, {0x14309e8, 0xc000458180}, 0xc000258000, 0x0) github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:467 +0x169 google.golang.org/grpc.(Server).processUnaryRPC(0xc0002781e0, {0x14356d0, 0xc00058c340}, 0xc000790000, 0xc000510720, 0x1a6cd58, 0x0) google.golang.org/grpc@v1.57.1/server.go:1358 +0xe15 google.golang.org/grpc.(Server).handleStream(0xc0002781e0, {0x14356d0, 0xc00058c340}, 0xc000790000, 0x0) google.golang.org/grpc@v1.57.1/server.go:1735 +0x9e7 google.golang.org/grpc.(Server).serveStreams.func1.1() google.golang.org/grpc@v1.57.1/server.go:970 +0xbb created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 39 google.golang.org/grpc@v1.57.1/server.go:981 +0x145

Error: The terraform-provider-azuread_v2.50.0_x5.exe 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.`

manicminer commented 1 month ago

Hi @hales8181, thanks for reporting this. The provider should never crash, however looking into this it seems like this may have been most likely caused by a network or connection issue between your Terraform host and the MS Graph API. Does this happen consistently or was it just a one-off error?

tonirvega commented 1 week ago

Hi @hales8181, thanks for reporting this. The provider should never crash, however looking into this it seems like this may have been most likely caused by a network or connection issue between your Terraform host and the MS Graph API. Does this happen consistently or was it just a one-off error?

I could see a similar error when I tried to destroy the resource. But I think this is related with a similar resource, privilegedaccess_groups_assignmentschedule_requests

╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The
│ plugin logs may contain more details.
╵

Stack trace from the terraform-provider-azuread_v2.52.0_x5 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0xb83f8d]

goroutine 97 [running]:
github.com/manicminer/hamilton/msgraph.(*PrivilegedAccessGroupAssignmentScheduleRequestsClient).Create(0xc000236380, {0x1095770, 0xc00027c7e0}, {0xc0002971a0, {0xc0002427c4, 0x6}, {0xf1871f, 0xb}, 0x0, 0x0, ...})
    github.com/manicminer/hamilton@v0.70.0/msgraph/privilegedaccess_groups_assignmentschedule_requests.go:75 +0x32d
github.com/hashicorp/terraform-provider-azuread/internal/services/identitygovernance.revokeAssignmentRequest({0x1095770, 0xc00027c7e0}, {0xc000155b00, {0x1095620, 0xc0003f29c0}, 0xc000174d00, 0x0, {0x10958c0, 0x16fa9e0}}, 0xc000236380, ...)
    github.com/hashicorp/terraform-provider-azuread/internal/services/identitygovernance/privileged_access_group_assignment_schedule_resource.go:294 +0x1d0
github.com/hashicorp/terraform-provider-azuread/internal/services/identitygovernance.(*PrivilegedAccessGroupAssignmentScheduleResource).Delete.PrivilegedAccessGroupAssignmentScheduleResource.Delete.func1({0x1095770, 0xc00027c7e0}, {0xc000155b00, {0x1095620, 0xc0003f29c0}, 0xc000174d00, 0x0, {0x10958c0, 0x16fa9e0}})
    github.com/hashicorp/terraform-provider-azuread/internal/services/identitygovernance/privileged_access_group_assignment_schedule_resource.go:271 +0x315
github.com/hashicorp/terraform-provider-azuread/internal/sdk.(*ResourceWrapper).Resource.func4({0x1095770, 0xc00027c7e0}, 0x0?, {0xde8f20?, 0xc000155b00?})
    github.com/hashicorp/terraform-provider-azuread/internal/sdk/wrapper_resource.go:72 +0x147
github.com/hashicorp/terraform-provider-azuread/internal/sdk.(*ResourceWrapper).Resource.(*ResourceWrapper).diagnosticsWrapper.diagnosticsWrapper.func12({0x1095770?, 0xc00027c7e0?}, 0x0?, {0xde8f20?, 0xc000155b00?})
    github.com/hashicorp/terraform-provider-azuread/internal/sdk/wrapper_resource.go:190 +0x59
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).delete(0xc000407420, {0x10956c8, 0xc0002e3e90}, 0xd?, {0xde8f20, 0xc000155b00})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:829 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000407420, {0x10956c8, 0xc0002e3e90}, 0xc0000c48f0, 0xc000174c80, {0xde8f20, 0xc000155b00})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:878 +0x605
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0003f2d38, {0x10956c8?, 0xc0002e3da0?}, 0xc000246690)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xdbc
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000350960, {0x10956c8?, 0xc0002e1ad0?}, 0xc000158c40)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:859 +0x56a
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xedede0?, 0xc000350960}, {0x10956c8, 0xc0002e1ad0}, 0xc0001589a0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:467 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002ac1e0, {0x109a310, 0xc000007d40}, 0xc00069c000, 0xc00046fce0, 0x16bcdb8, 0x0)
    google.golang.org/grpc@v1.57.1/server.go:1358 +0xe15
google.golang.org/grpc.(*Server).handleStream(0xc0002ac1e0, {0x109a310, 0xc000007d40}, 0xc00069c000, 0x0)
    google.golang.org/grpc@v1.57.1/server.go:1735 +0x9e7
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.57.1/server.go:970 +0xbb
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 25
    google.golang.org/grpc@v1.57.1/server.go:981 +0x145

Error: The terraform-provider-azuread_v2.52.0_x5 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.