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

Crashes when importing xray_repository_config #134

Closed
marcosdiez opened this issue Sep 5, 2023 · 3 comments · Fixed by #135
Closed

Crashes when importing xray_repository_config #134

marcosdiez opened this issue Sep 5, 2023 · 3 comments · Fixed by #135
Assignees
Labels
bug Something isn't working

Comments

@marcosdiez
Copy link

if one types

terraform import xray_repository_config.xray-repo-config collection-container-prod-local

one gets

xray_repository_config.xray-repo-config: Importing from ID "collection-container-prod-local"...
xray_repository_config.xray-repo-config: Import prepared!
  Prepared xray_repository_config for import
xray_repository_config.xray-repo-config: Refreshing state... [id=collection-container-prod-local]
╷
│ Error: Request cancelled
│
│ The plugin.(*GRPCProvider).ReadResource request was cancelled.
╵


Stack trace from the terraform-provider-xray_v1.15.0 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1052d3290]

goroutine 41 [running]:
github.com/jfrog/terraform-provider-xray/pkg/xray.resourceXrayRepositoryConfig.func8(0x140001111d0, {0x14000452f00, 0x6}, {0x14000307aa0, 0x6})
	github.com/jfrog/terraform-provider-xray/pkg/xray/resource_xray_repository_config.go:376 +0x170
github.com/jfrog/terraform-provider-xray/pkg/xray.resourceXrayRepositoryConfig.func12({0x1400051a3c0?, 0x14000338160?}, {{0x140001bf9c0?, 0x10530030b?}, 0x140001111d0?, 0x0?}, 0xd?, {0x14000452f00, 0x6}, {0x14000307aa0, ...})
	github.com/jfrog/terraform-provider-xray/pkg/xray/resource_xray_repository_config.go:429 +0x108
github.com/jfrog/terraform-provider-xray/pkg/xray.resourceXrayRepositoryConfig.func14({0x1055b2268, 0x140005485a0}, 0x140001e0900, {0x105526d00?, 0x1400047e870})
	github.com/jfrog/terraform-provider-xray/pkg/xray/resource_xray_repository_config.go:482 +0x568
github.com/jfrog/terraform-provider-shared/util/sdk.applyTelemetry.func1({0x1055b2268?, 0x140005485a0}, 0x0?, {0x105526d00?, 0x1400047e870})
	github.com/jfrog/[email protected]/util/sdk/sdk.go:234 +0x200
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x14000498c40, {0x1055b22a0, 0x140002e8fc0}, 0xd?, {0x105526d00, 0x1400047e870})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:750 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0x14000498c40, {0x1055b22a0, 0x140002e8fc0}, 0x140001971e0, {0x105526d00, 0x1400047e870})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1044 +0x494
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0x14000317968, {0x1055b22a0?, 0x140002e8ea0?}, 0x140004b2b80)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:616 +0x40c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0x140004b4000, {0x1055b22a0?, 0x140002e8360?}, 0x140005482a0)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:751 +0x3ec
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x10557b900?, 0x140004b4000}, {0x1055b22a0, 0x140002e8360}, 0x140001dc070, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:386 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400046e000, {0x1055b4ee0, 0x140002a89c0}, 0x140004f2000, 0x1400047f3b0, 0x105a4df50, 0x0)
	google.golang.org/[email protected]/server.go:1337 +0xc7c
google.golang.org/grpc.(*Server).handleStream(0x1400046e000, {0x1055b4ee0, 0x140002a89c0}, 0x140004f2000, 0x0)
	google.golang.org/[email protected]/server.go:1714 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	google.golang.org/[email protected]/server.go:959 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:957 +0x170

Error: The terraform-provider-xray_v1.15.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.

The terraform for it is trivial:

terraform {
  required_providers {
    xray = {
      source = "jfrog/xray"
      version = "1.15.0"
    }
  }
}

provider "xray" {
   url = "https://XXXXX.jfrog.io"
}

resource "xray_repository_config" "xray-repo-config" {
  repo_name = "anyname"
}
@marcosdiez marcosdiez added the bug Something isn't working label Sep 5, 2023
@alexhung alexhung assigned alexhung and unassigned danielmkn Sep 5, 2023
@alexhung
Copy link
Member

alexhung commented Sep 5, 2023

@marcosdiez It's not valid for the repository configuration to have no config or path_config attribute. I'll update the provider to enforce that rule. In the meantime, you need to include either/or both attributes (depending on the package type).

@marcosdiez
Copy link
Author

Hi @alexhung

I think the problem is something else. I think it's by repository type. I tried with multiple times and I got deterministic results. Check it out !

I could successfully import:

  • Remote / RPM
  • Local / Generic

I could NOT import (stacktrace):

  • Local / Docker
  • Remote / Docker
  • Remote / NPM
  • Local / Docker

Please take a look and let me know

Marcos

@alexhung
Copy link
Member

alexhung commented Sep 6, 2023

@marcosdiez Exactly! For those package types, you will need to include config or path_config attributes in order for import to be successful. Similarly if you are to create new repo config for those package types.

alexhung added a commit that referenced this issue Sep 6, 2023
Add validation to ensure either 'config' or 'path_config' attribute is set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants