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

plugin crashing for okta_inline_hook headers #1169

Closed
ghost opened this issue Jun 17, 2022 · 5 comments · Fixed by #1337
Closed

plugin crashing for okta_inline_hook headers #1169

ghost opened this issue Jun 17, 2022 · 5 comments · Fixed by #1337
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Jun 17, 2022

Getting this error when I try to add headers on okta_inline_hook.

Terraform resource:

resource "okta_inline_hook" "my_inline_hook" {
  name    = "....."
  version = "1.0.0"
  type    = "com.okta.oauth2.tokens.transform"
  
  headers {
    key   = "my_header"
    value = "some_value"
  }

  channel = {
   .....
  }
}

Error on terraform apply:

│ 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-okta_v3.29.0 plugin:

panic: interface conversion: interface {} is nil, not string

goroutine 38 [running]:
github.com/okta/terraform-provider-okta/okta.buildInlineChannel(0x100cc54)
	github.com/okta/terraform-provider-okta/okta/resource_okta_inline_hooks.go:240 +0x6d4
github.com/okta/terraform-provider-okta/okta.buildInlineHook(0x1176592d2ab)
	github.com/okta/terraform-provider-okta/okta/resource_okta_inline_hooks.go:218 +0x145
github.com/okta/terraform-provider-okta/okta.resourceInlineHookUpdate({0x1b6e3c8, 0xc000288840}, 0xc00009ed00, {0x18fb7c0, 0xc00048e380})
	github.com/okta/terraform-provider-okta/okta/resource_okta_inline_hooks.go:187 +0x98
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0002d9340, {0x1b6e400, 0xc0004e9440}, 0xd, {0x18fb7c0, 0xc00048e380})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.17.0/helper/schema/resource.go:741 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0002d9340, {0x1b6e400, 0xc0004e9440}, 0xc000110750, 0xc00009eb80, {0x18fb7c0, 0xc00048e380})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.17.0/helper/schema/resource.go:847 +0x9e5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000482090, {0x1b6e358, 0xc00064ec40}, 0xc0000aa3c0)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.17.0/helper/schema/grpc_provider.go:1021 +0xe3c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000492000, {0x1b6e400, 0xc0004e8a80}, 0xc0004e2150)
	github.com/hashicorp/terraform-plugin-go@v0.9.1/tfprotov5/tf5server/server.go:812 +0x56b
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x19da000, 0xc000492000}, {0x1b6e400, 0xc0004e8a80}, 0xc0003e6ae0, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.9.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00021ec40, {0x1b7e760, 0xc00038bd40}, 0xc0003c2120, 0xc000461bf0, 0x2146de0, 0x0)
	google.golang.org/grpc@v1.46.0/server.go:1283 +0xcf2
google.golang.org/grpc.(*Server).handleStream(0xc00021ec40, {0x1b7e760, 0xc00038bd40}, 0xc0003c2120, 0x0)
	google.golang.org/grpc@v1.46.0/server.go:1620 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.46.0/server.go:922 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.46.0/server.go:920 +0x294

Error: The terraform-provider-okta_v3.29.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.

2022-06-17T11:08:29.347-0500 [DEBUG] provider: plugin exited
@monde
Copy link
Collaborator

monde commented Jun 17, 2022

Thanks @nisargpansuria I can definitely see the logical flaw causing this panic https://github.com/okta/terraform-provider-okta/blob/master/okta/resource_okta_inline_hooks.go#L232-L244 if you have an empty auth property in your config. Looking at the documentation https://registry.terraform.io/providers/okta/okta/latest/docs/resources/inline_hook and your example compared to the documentation example do you have an auth property that is empty?

resource "okta_inline_hook" "example" {
  name    = "example"
  version = "1.0.0"
  type    = "com.okta.oauth2.tokens.transform"

  channel = {
    version = "1.0.0"
    uri     = "https://example.com/test"
    method  = "POST"
  }

  auth = {
    key   = "Authorization"
    type  = "HEADER"
    value = "secret"
  }
}

@monde monde self-assigned this Jun 17, 2022
@monde monde added the waiting-response Waiting on collaborator to responde to follow on disucussion label Jun 17, 2022
@ghost
Copy link
Author

ghost commented Jun 17, 2022

@monde Yes, auth property was empty. When I added a dummy auth header with auth = { .. }, it let me set custom headers now from terraform (this exception is gone). So for now to bypass this exception I will need to set something in using auth = { .. } even though I am not using it, and use headers { .. } as I intended.

This seems like a logical flaw in this provider. Terraform and Okta console is behaving differently. On the Okta console, the authentication field is not required to set custom headers on inline hook.

@monde monde added bug and removed waiting-response Waiting on collaborator to responde to follow on disucussion labels Jun 17, 2022
@monde
Copy link
Collaborator

monde commented Jun 17, 2022

Thank for the feedback @nisargpansuria . I'll label this a bug given the inconsistency in behavior you are describing and keep this issue open to address.

@monde monde removed their assignment Aug 15, 2022
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days

@monde
Copy link
Collaborator

monde commented Oct 28, 2022

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

Successfully merging a pull request may close this issue.

1 participant