goauthentik / terraform-provider-authentik

Manage https://goauthentik.io with terraform.
https://registry.terraform.io/providers/goauthentik/authentik/latest/docs
GNU General Public License v3.0
58 stars 16 forks source link

app_password crashes #507

Closed Zapfmeister closed 1 month ago

Zapfmeister commented 1 month ago

Hi,

im trying to provision an app_password and it was working in a former release, but now it crashes (Newer authentik release and newer authentik terraform.)

Terraform Authentik Release 2024.4.1 Authentik Release 2024.4

Terraform Task:

resource "authentik_token" "netbird_Test" {
  user            = authentik_user.user["netbird"].id
  identifier      = "netbird_serviceaccount"
  expires         = null
  expiring        = false
  intent          = "app_password" # Allowed values: verification, api, recovery, app_password 
  depends_on      = [authentik_user.user]
}

Crash Debug:

{"pk":"204c0be7-6bd2-4a01-b93e-0974bab853be","managed":null,"identifier":"netbird_serviceaccount","intent":"app_password","user":14,"user_obj":{"pk":14,"username":"netbird","name":"netbird serviceaccount","is_active":true,"last_login":null,"is_superuser":true,"groups":["1eb4f88c-6827-49bd-b6cd-0b3bd83a5b54"],"groups_obj":[{"pk":"1eb4f88c-6827-49bd-b6cd-0b3bd83a5b54","num_pk":40816,"name":"ZF_SuperAdmin","is_superuser":true,"parent":null,"parent_name":null,"attributes":{}}],"email":"","avatar":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NHB4IiBoZWlnaHQ9IjY0cHgiIHZpZXdCb3g9IjAgMCA2NCA2NCIgdmVyc2lvbj0iMS4xIj48cmVjdCBmaWxsPSIjMzczN2M4IiBjeD0iMzIiIGN5PSIzMiIgd2lkdGg9IjY0IiBoZWlnaHQ9IjY0IiByPSIzMiIvPjx0ZXh0IHg9IjUwJSIgeT0iNTAlIiBzdHlsZT0iY29sb3I6ICNmZmY7IGxpbmUtaGVpZ2h0OiAxOyBmb250LWZhbWlseTogJ1JlZEhhdFRleHQnLCdPdmVycGFzcycsb3ZlcnBhc3MsaGVsdmV0aWNhLGFyaWFsLHNhbnMtc2VyaWY7ICIgZmlsbD0iI2ZmZiIgYWxpZ25tZW50LWJhc2VsaW5lPSJtaWRkbGUiIGRvbWluYW50LWJhc2VsaW5lPSJtaWRkbGUiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGZvbnQtc2l6ZT0iMjgiIGZvbnQtd2VpZ2h0PSI0MDAiIGR5PSIuMWVtIj5OUzwvdGV4dD48L3N2Zz4=","attributes":{},"uid":"7b25ad0bbd6bf50ce0890819c42e197b8eb9c806efeaf4656536712a575982f3","path":"users/serviceaccounts","type":"service_account","uuid":"812a89ba-cedc-4fc9-81cf-ebe2baadd08c"},"description":"","expires":null,"expiring":false}: timestamp=2024-05-08T14:57:48.412Z
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: panic: runtime error: invalid memory address or nil pointer dereference
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x117f97c]
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: goroutine 35 [running]:
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: goauthentik.io/terraform-provider-authentik/internal/provider.resourceTokenRead({0x16732c0, 0xc0003bcf50}, 0xc00050b880, {0x120cb60?, 0xc000302118})
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   goauthentik.io/terraform-provider-authentik/internal/provider/resource_token.go:125 +0x2dc
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: goauthentik.io/terraform-provider-authentik/internal/provider.resourceTokenCreate({0x16732c0, 0xc0003bcf50}, 0x14caedc?, {0x120cb60?, 0xc000302118?})
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   goauthentik.io/terraform-provider-authentik/internal/provider/resource_token.go:109 +0x134
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: goauthentik.io/terraform-provider-authentik/internal/provider.tr.func1({0x16732c0, 0xc0003bcf50}, 0x0?, {0x120cb60, 0xc000302118})
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   goauthentik.io/terraform-provider-authentik/internal/provider/tracing.go:18 +0x15f
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc0001bfb20, {0x1673218, 0xc000800d80}, 0xd?, {0x120cb60, 0xc000302118})
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:778 +0x11b
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0001bfb20, {0x1673218, 0xc000800d80}, 0xc000744680, 0xc00050b700, {0x120cb60, 0xc000302118})
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:909 +0xa89
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0004c9758, {0x1673218?, 0xc000800c90?}, 0xc0005305f0)
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:1078 +0xdbc
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0003ba1e0, {0x1673218?, 0xc000800270?}, 0xc0003bc380)
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/tf5server/server.go:846 +0x3d0
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1446c80?, 0xc0003ba1e0}, {0x1673218, 0xc000800270}, 0xc00050a080, 0x0)
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x169
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: google.golang.org/grpc.(*Server).processUnaryRPC(0xc00033c200, {0x1673218, 0xc0008001e0}, {0x16777a0, 0xc000014680}, 0xc000528000, 0xc000185fb0, 0x2008838, 0x0)
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   google.golang.org/grpc@v1.61.1/server.go:1385 +0xe03
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: google.golang.org/grpc.(*Server).handleStream(0xc00033c200, {0x16777a0, 0xc000014680}, 0xc000528000)
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   google.golang.org/grpc@v1.61.1/server.go:1796 +0xfec
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: google.golang.org/grpc.(*Server).serveStreams.func2.1()
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   google.golang.org/grpc@v1.61.1/server.go:1029 +0x8b
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1: created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 55
2024-05-08T14:57:48.416Z [DEBUG] provider.terraform-provider-authentik_v2024.4.1:   google.golang.org/grpc@v1.61.1/server.go:1040 +0x135
2024-05-08T14:57:48.418Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/goauthentik/authentik/2024.4.1/linux_amd64/terraform-provider-authentik_v2024.4.1 pid=192841 error="exit status 2"
2024-05-08T14:57:48.418Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-05-08T14:57:48.418Z [ERROR] plugin.(*GRPCProvider).ApplyResourceChange: error="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-05-08T14:57:48.436Z [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-05-08T14:57:48.436Z [ERROR] vertex "authentik_token.netbird_Test" error: Plugin did not respond
╷
│ Error: Plugin did not respond
│
│   with authentik_token.netbird_Test,
│   on users.tf line 44, in resource "authentik_token" "netbird_Test":
│   44: resource "authentik_token" "netbird_Test" {
│
│ 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-authentik_v2024.4.1 plugin:

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

goroutine 35 [running]:
goauthentik.io/terraform-provider-authentik/internal/provider.resourceTokenRead({0x16732c0, 0xc0003bcf50}, 0xc00050b880, {0x120cb60?, 0xc000302118})
    goauthentik.io/terraform-provider-authentik/internal/provider/resource_token.go:125 +0x2dc
goauthentik.io/terraform-provider-authentik/internal/provider.resourceTokenCreate({0x16732c0, 0xc0003bcf50}, 0x14caedc?, {0x120cb60?, 0xc000302118?})
    goauthentik.io/terraform-provider-authentik/internal/provider/resource_token.go:109 +0x134
goauthentik.io/terraform-provider-authentik/internal/provider.tr.func1({0x16732c0, 0xc0003bcf50}, 0x0?, {0x120cb60, 0xc000302118})
    goauthentik.io/terraform-provider-authentik/internal/provider/tracing.go:18 +0x15f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc0001bfb20, {0x1673218, 0xc000800d80}, 0xd?, {0x120cb60, 0xc000302118})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:778 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0001bfb20, {0x1673218, 0xc000800d80}, 0xc000744680, 0xc00050b700, {0x120cb60, 0xc000302118})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:909 +0xa89
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0004c9758, {0x1673218?, 0xc000800c90?}, 0xc0005305f0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:1078 +0xdbc
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0003ba1e0, {0x1673218?, 0xc000800270?}, 0xc0003bc380)
    github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/tf5server/server.go:846 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1446c80?, 0xc0003ba1e0}, {0x1673218, 0xc000800270}, 0xc00050a080, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00033c200, {0x1673218, 0xc0008001e0}, {0x16777a0, 0xc000014680}, 0xc000528000, 0xc000185fb0, 0x2008838, 0x0)
    google.golang.org/grpc@v1.61.1/server.go:1385 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc00033c200, {0x16777a0, 0xc000014680}, 0xc000528000)
    google.golang.org/grpc@v1.61.1/server.go:1796 +0xfec
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    google.golang.org/grpc@v1.61.1/server.go:1029 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 55
    google.golang.org/grpc@v1.61.1/server.go:1040 +0x135

Error: The terraform-provider-authentik_v2024.4.1 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.

2024-05-08T14:57:48.450Z [DEBUG] provider: plugin exited