okta / terraform-provider-okta

A Terraform provider to manage Okta resources, enabling infrastructure-as-code provisioning and management of users, groups, applications, and other Okta objects.
https://registry.terraform.io/providers/okta/okta
Mozilla Public License 2.0
252 stars 204 forks source link

Panic runtime error in 3.43.0 on okta_policy_mfa_default resource #1481

Closed stmyers closed 1 year ago

stmyers commented 1 year ago

Community Note

Terraform Version

v1.3.9

Affected Resource(s)

Terraform Configuration Files

resource "okta_policy_mfa_default" "default_mfa_enrollment" {
  is_oie = true

  okta_password = {
    enroll = "REQUIRED"
  }
  okta_verify = {
    enroll = "OPTIONAL"
  }
  webauthn = {
    enroll = "OPTIONAL"
  }
  okta_email = {
    enroll = "OPTIONAL"
  }
  security_question = {
    enroll = "NOT_ALLOWED"
  }
  yubikey_token = {
    enroll = "OPTIONAL"
  }
}

Important Factoids

I pinned provider version to 3.42.0 to prevent the panic

Panic Output

Stack trace from the terraform-provider-okta_v3.43.0 plugin:

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

goroutine 490 [running]:
github.com/okta/terraform-provider-okta/okta.syncSettings(0x101f628?, 0x0)
github.com/okta/terraform-provider-okta/okta/resource_okta_policy_mfa.go:155 +0x1d
github.com/okta/terraform-provider-okta/okta.resourcePolicyMfaDefaultRead({0x101f628?, 0xc000502b40?}, 0x0?, {0xd88800?, 0xc000208120?})
github.com/okta/terraform-provider-okta/okta/resource_okta_policy_mfa_default.go:57 +0xe6
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc00044ce00, {0x101f660, 0xc0009f9d10}, 0xd?, {0xd88800, 0xc000208120})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:724 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc00044ce00, {0x101f660, 0xc0009f9d10}, 0xc0005cb790, {0xd88800, 0xc000208120})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000498738, {0x101f660?, 0xc0009f9bf0?}, 0xc00051a7c0)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc000271ea0, {0x101f660?, 0xc0001bddd0?}, 0xc000523440)
github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:748 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xe73ec0?, 0xc000271ea0}, {0x101f660, 0xc0001bddd0}, 0xc00059c690, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001d01e0, {0x10234d8, 0xc0004cfd40}, 0xc0006c4b40, 0xc0004bdce0, 0x15c1410, 0x0)
google.golang.org/grpc@v1.51.0/server.go:1340 +0xd33
google.golang.org/grpc.(*Server).handleStream(0xc0001d01e0, {0x10234d8, 0xc0004cfd40}, 0xc0006c4b40, 0x0)
google.golang.org/grpc@v1.51.0/server.go:1713 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/grpc@v1.51.0/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.51.0/server.go:963 +0x28a

Error: The terraform-provider-okta_v3.43.0 plugin crashed!

Appears to be these lines https://github.com/okta/terraform-provider-okta/blob/3529685f132ddd99c67f92c1e36671e8afb42b20/okta/resource_okta_policy_mfa.go#L155 https://github.com/okta/terraform-provider-okta/blob/3529685f132ddd99c67f92c1e36671e8afb42b20/okta/resource_okta_policy_mfa_default.go#L57

monde commented 1 year ago

Thanks @stmyers , I'll try and get a bug fix release out real quick, there was another panic issue as well that was reported.

Okta internal reference: https://oktainc.atlassian.net/browse/OKTA-586216

stmyers commented 1 year ago

I saw the other issue (#1480) you're referencing (I assume) but that is for an older version (3.32) so I think that's unrelated to this issue.

virgofx commented 1 year ago

Not going to create another issue -- But going to add one more stack trace here:

3.43.0 / OIE

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

goroutine 155 [running]:
github.com/okta/terraform-provider-okta/okta.resourcePolicyPasswordDefaultRead({0x1925408?, 0xc000789770?}, 0xc0002d2f80, {0x1689a00?, 0xc0002f9680?})
        github.com/okta/terraform-provider-okta/okta/resource_okta_policy_password_default.go:215 +0xfe
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0004a2fc0, {0x1925440, 0xc0002cb620}, 0xd?, {0x1689a00, 0xc0002f9680})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:724 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0004a2fc0, {0x1925440, 0xc0002cb620}, 0xc000881110, {0x1689a00, 0xc0002f9680}) 
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00068e270, {0x1925440?, 0xc0002cacc0?}, 0xc000886c40)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc000246000, {0x1925440?, 0xc00051b980?}, 0xc000053380)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:748 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x1775e00?, 0xc000246000}, {0x1925440, 0xc00051b980}, 0xc0001a4850, 0x0) 
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001b61e0, {0x19292b8, 0xc0005841a0}, 0xc000449e60, 0xc00068dce0, 0x1ed39b0, 0x0)
        google.golang.org/grpc@v1.51.0/server.go:1340 +0xd33
google.golang.org/grpc.(*Server).handleStream(0xc0001b61e0, {0x19292b8, 0xc0005841a0}, 0xc000449e60, 0x0)
        google.golang.org/grpc@v1.51.0/server.go:1713 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.51.0/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.51.0/server.go:963 +0x28a

Error: The terraform-provider-okta_v3.43.0.exe plugin crashed!
monde commented 1 year ago

Right, that integer pointers fix I brought in to fix JSON serialization of ints opened up a bunch of small bugs. I had been avoiding fixing that. I am working on fix release, hoping to get that out today.

virgofx commented 1 year ago

Confirmed that the above stack trace I posted (not the author's original) is fixed via 3.44.0

monde commented 1 year ago

Awesome, good to hear @virgofx

Closing this issue now, fix released in v3.44.0