Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expired session causes a plugin crash #62

Open
bachya opened this issue Jan 4, 2022 · 0 comments
Open

Expired session causes a plugin crash #62

bachya opened this issue Jan 4, 2022 · 0 comments

Comments

@bachya
Copy link

bachya commented Jan 4, 2022

TL;DR

I use the op CLI tool to login to 1Password and create an OP_SESSION_* session. It seems that when the session expires, this plugin crashes.

Example Terraform

When I ran terraform plan/refresh/apply on this sample (still with an expired session), I saw this:

terraform {
  required_providers {
    onepassword = {
      source = "milosbackonja/1password"
      version = "1.1.0"
    }
}

provider "onepassword" {}

data "onepassword_item_password" "my_item" {
    name  = "MyItem"
    vault = "Secrets"
}

output "test" {
    sensitive = true
    value = data.onepassword_item_password.my_item
}

Stacktrace

Stack trace from the terraform-provider-1password_v1.1.0 plugin:

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

goroutine 30 [running]:
github.com/anasinnyk/terraform-provider-1password/onepassword.resourceItemPasswordRead(0x19418a0, 0xc000810060, 0xc0000f8300, 0x173d040, 0xc00038e520, 0xc000730c30, 0xc0007b3910, 0x100c9b8)
        github.com/anasinnyk/terraform-provider-1password/onepassword/resource_item_password.go:75 +0x18d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0003eb3f0, 0x1941820, 0xc00028c240, 0xc0000f8300, 0x173d040, 0xc00038e520, 0x0, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.0.0/helper/schema/resource.go:288 +0x1ec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc0003eb3f0, 0x1941820, 0xc00028c240, 0xc0005089a0, 0x173d040, 0xc00038e520, 0xc00038e520, 0xc0005089a0, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.0.0/helper/schema/resource.go:489 +0xff
github.com/hashicorp/terraform-plugin-sdk/v2/internal/helper/plugin.(*GRPCProviderServer).ReadDataSource(0xc0001e0640, 0x1941820, 0xc00028c240, 0xc00028c1c0, 0xc0001e0640, 0xc0001e0650, 0x185a058)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.0.0/internal/helper/plugin/grpc_provider.go:1102 +0x4c5
github.com/hashicorp/terraform-plugin-sdk/v2/internal/tfplugin5._Provider_ReadDataSource_Handler.func1(0x1941820, 0xc00028c240, 0x17dcd60, 0xc00028c1c0, 0xc00028c240, 0x1773c80, 0x19194d0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.0.0/internal/tfplugin5/tfplugin5.pb.go:3348 +0x86
github.com/hashicorp/terraform-plugin-sdk/v2/plugin.Serve.func3.1(0x19418e0, 0xc0004821b0, 0x17dcd60, 0xc00028c1c0, 0xc000616480, 0xc0006164a0, 0xc0007f5ba0, 0x11b81c8, 0x17c7a20, 0xc0004821b0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.0.0/plugin/serve.go:76 +0x87
github.com/hashicorp/terraform-plugin-sdk/v2/internal/tfplugin5._Provider_ReadDataSource_Handler(0x17fdb60, 0xc0001e0640, 0x19418e0, 0xc0004821b0, 0xc0007ec1e0, 0xc000508ac0, 0x19418e0, 0xc0004821b0, 0xc000490000, 0x7d)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.0.0/internal/tfplugin5/tfplugin5.pb.go:3350 +0x14b
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001fcfc0, 0x1949c60, 0xc000602900, 0xc00048c000, 0xc000192d20, 0x1e49910, 0x0, 0x0, 0x0)
        google.golang.org/grpc@v1.30.0/server.go:1171 +0x50a
google.golang.org/grpc.(*Server).handleStream(0xc0001fcfc0, 0x1949c60, 0xc000602900, 0xc00048c000, 0x0)
        google.golang.org/grpc@v1.30.0/server.go:1494 +0xccd
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000036280, 0xc0001fcfc0, 0x1949c60, 0xc000602900, 0xc00048c000)
        google.golang.org/grpc@v1.30.0/server.go:834 +0xa1
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.30.0/server.go:832 +0x204

Error: The terraform-provider-1password_v1.1.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.

Background

After the plugin crashed, I executed op logout (really, any op command would have worked) and received a console log explaining that my session had expired:

[ERROR] 2022/01/04 13:09:24 session expired, sign in to create a new session

Creating a new session with op allowed the plugin to work correctly again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant