chainguard-dev / terraform-provider-apko

https://registry.terraform.io/providers/chainguard-dev/apko/latest
Mozilla Public License 2.0
14 stars 14 forks source link

provider crashes if missing default_archs #84

Open jdolitsky opened 1 year ago

jdolitsky commented 1 year ago

using the following (missing the default_archs array):

provider "apko" {
  extra_repositories = ["https://dl-cdn.alpinelinux.org/alpine/edge/main"]
}

causes the following error

$ terraform apply
module.latest.module.this.data.apko_config.this: Reading...
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more
│ details.
╵

Stack trace from the terraform-provider-apko_v0.8.5 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 44 [running]:
github.com/chainguard-dev/terraform-provider-apko/internal/provider.unify({0x1400004eaa0, 0x5, 0x104faaf90?}, {0x105d49d48, 0x0, 0x0})
    github.com/chainguard-dev/terraform-provider-apko/internal/provider/config_data_source.go:255 +0xf10
github.com/chainguard-dev/terraform-provider-apko/internal/provider.(*ConfigDataSource).resolvePackageList(_, {{{0x140004c1650, 0x1, 0x1}, {0x0, 0x0, 0x0}, {0x1400004eaa0, 0x5, 0x5}}, ...})
    github.com/chainguard-dev/terraform-provider-apko/internal/provider/config_data_source.go:221 +0x2ec
github.com/chainguard-dev/terraform-provider-apko/internal/provider.(*ConfigDataSource).Read(0x140004de420, {0x1054a73b0, 0x140001aede0}, {{{{0x1054ad8c8, 0x140002a5d70}, {0x1052e54a0, 0x140002a4ed0}}, {0x1054af7b8, 0x1400026cb40}}, {{{0x0, ...}, ...}, ...}}, ...)
    github.com/chainguard-dev/terraform-provider-apko/internal/provider/config_data_source.go:141 +0x788
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ReadDataSource(0x140001fb340, {0x1054a73b0, 0x140001aede0}, 0x140001aeed0, 0x140005b35e8)
    github.com/hashicorp/terraform-plugin-framework@v1.2.0/internal/fwserver/server_readdatasource.go:75 +0x394
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ReadDataSource(0x140001fb340, {0x1054a73b0?, 0x140001aec90?}, 0x1400037c4e0)
    github.com/hashicorp/terraform-plugin-framework@v1.2.0/internal/proto6server/server_readdatasource.go:52 +0x1b0
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadDataSource(0x140001b6a00, {0x1054a73b0?, 0x140001ae330?}, 0x1400004e5a0)
    github.com/hashicorp/terraform-plugin-go@v0.15.0/tfprotov6/tf6server/server.go:656 +0x368
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadDataSource_Handler({0x10544e460?, 0x140001b6a00}, {0x1054a73b0, 0x140001ae330}, 0x14000226930, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.15.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:455 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400027a000, {0x1054adfe0, 0x14000237520}, 0x1400027f560, 0x14000615dd0, 0x105d00ab0, 0x0)
    google.golang.org/grpc@v1.54.0/server.go:1345 +0xc64
google.golang.org/grpc.(*Server).handleStream(0x1400027a000, {0x1054adfe0, 0x14000237520}, 0x1400027f560, 0x0)
    google.golang.org/grpc@v1.54.0/server.go:1722 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.2()
    google.golang.org/grpc@v1.54.0/server.go:966 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.54.0/server.go:964 +0x290

Error: The terraform-provider-apko_v0.8.5 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.
mattmoor commented 1 year ago

@joshrwolf I believe this is fixed?