Provider crashes if protocol is omitted from base URL #6

Open
opened 2023-04-18 17:55:05 +00:00 by pim · 2 comments
Contributor

If you omit the protocol from the gitea provider's base_url parameter, e.g. "https://", the provider crashes.
I attached the log below.
Seems to be a problem in the Gitea golang SDK but could also be handled in the provider.

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Request cancelled
│
│   with provider["registry.terraform.io/go-gitea/gitea"],
│   on main.tf line 10, in provider "gitea":
│   10: provider "gitea" {
│
│ The plugin.(*GRPCProvider).ConfigureProvider request was cancelled.
╵

Stack trace from the terraform-provider-gitea_v0.1.0 plugin:

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

goroutine 50 [running]:
code.gitea.io/sdk/gitea.(*Client).doRequest(0x0, {0xd5659e, 0x3}, {0xd5738c, 0x5}, 0x0, {0x0?, 0x0})
	code.gitea.io/sdk/gitea@v0.15.1/client.go:206 +0x76
code.gitea.io/sdk/gitea.(*Client).getResponse(0xf0?, {0xd5659e?, 0xc00026c000?}, {0xd5738c?, 0xc00056d738?}, 0x40dcc7?, {0x0?, 0x0?})
	code.gitea.io/sdk/gitea@v0.15.1/client.go:289 +0x7d
code.gitea.io/sdk/gitea.(*Client).getParsedResponse(0xc0000f7d10?, {0xd5659e?, 0x72e9cb?}, {0xd5738c?, 0xc000108280?}, 0xc00056d701?, {0x0?, 0x0?}, {0xbfd840, 0xc00026c000})
	code.gitea.io/sdk/gitea@v0.15.1/client.go:311 +0x36
code.gitea.io/sdk/gitea.(*Client).GetMyUserInfo(0xc0000ebc50?)
	code.gitea.io/sdk/gitea@v0.15.1/user.go:67 +0x65
code.gitea.io/terraform-provider-gitea/gitea.(*Config).Client(0xc00056d8e8)
	code.gitea.io/terraform-provider-gitea/gitea/config.go:72 +0x407
code.gitea.io/terraform-provider-gitea/gitea.providerConfigure(0xc00048eae0?)
	code.gitea.io/terraform-provider-gitea/gitea/provider.go:113 +0x27d
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Configure(0xc00014fc00, 0xc0000ac478?)
	github.com/hashicorp/terraform-plugin-sdk@v1.13.0/helper/schema/provider.go:275 +0xbd
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).Configure(0xc000012ba0, {0xc0000bc300?, 0x5b5f66?}, 0xc0000bc300)
	github.com/hashicorp/terraform-plugin-sdk@v1.13.0/internal/helper/plugin/grpc_provider.go:487 +0x1d2
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_Configure_Handler({0xd2c5e0?, 0xc000012ba0}, {0xed97a8, 0xc0000f74a0}, 0xc0000be360, 0x0)
	github.com/hashicorp/terraform-plugin-sdk@v1.13.0/internal/tfplugin5/tfplugin5.pb.go:3251 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000002480, {0xedd060, 0xc0001f2000}, 0xc0000c0200, 0xc000097770, 0x13cc738, 0x0)
	google.golang.org/grpc@v1.27.1/server.go:1024 +0xd4f
google.golang.org/grpc.(*Server).handleStream(0xc000002480, {0xedd060, 0xc0001f2000}, 0xc0000c0200, 0x0)
	google.golang.org/grpc@v1.27.1/server.go:1313 +0xa25
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	google.golang.org/grpc@v1.27.1/server.go:722 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.27.1/server.go:720 +0xea

Error: The terraform-provider-gitea_v0.1.0 plugin crashed!
If you omit the protocol from the gitea provider's base_url parameter, e.g. "https://", the provider crashes. I attached the log below. Seems to be a problem in the Gitea golang SDK but could also be handled in the provider. ```shell Planning failed. Terraform encountered an error while generating this plan. ╷ │ Error: Request cancelled │ │ with provider["registry.terraform.io/go-gitea/gitea"], │ on main.tf line 10, in provider "gitea": │ 10: provider "gitea" { │ │ The plugin.(*GRPCProvider).ConfigureProvider request was cancelled. ╵ Stack trace from the terraform-provider-gitea_v0.1.0 plugin: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x90 pc=0x72f7b6] goroutine 50 [running]: code.gitea.io/sdk/gitea.(*Client).doRequest(0x0, {0xd5659e, 0x3}, {0xd5738c, 0x5}, 0x0, {0x0?, 0x0}) code.gitea.io/sdk/gitea@v0.15.1/client.go:206 +0x76 code.gitea.io/sdk/gitea.(*Client).getResponse(0xf0?, {0xd5659e?, 0xc00026c000?}, {0xd5738c?, 0xc00056d738?}, 0x40dcc7?, {0x0?, 0x0?}) code.gitea.io/sdk/gitea@v0.15.1/client.go:289 +0x7d code.gitea.io/sdk/gitea.(*Client).getParsedResponse(0xc0000f7d10?, {0xd5659e?, 0x72e9cb?}, {0xd5738c?, 0xc000108280?}, 0xc00056d701?, {0x0?, 0x0?}, {0xbfd840, 0xc00026c000}) code.gitea.io/sdk/gitea@v0.15.1/client.go:311 +0x36 code.gitea.io/sdk/gitea.(*Client).GetMyUserInfo(0xc0000ebc50?) code.gitea.io/sdk/gitea@v0.15.1/user.go:67 +0x65 code.gitea.io/terraform-provider-gitea/gitea.(*Config).Client(0xc00056d8e8) code.gitea.io/terraform-provider-gitea/gitea/config.go:72 +0x407 code.gitea.io/terraform-provider-gitea/gitea.providerConfigure(0xc00048eae0?) code.gitea.io/terraform-provider-gitea/gitea/provider.go:113 +0x27d github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Configure(0xc00014fc00, 0xc0000ac478?) github.com/hashicorp/terraform-plugin-sdk@v1.13.0/helper/schema/provider.go:275 +0xbd github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).Configure(0xc000012ba0, {0xc0000bc300?, 0x5b5f66?}, 0xc0000bc300) github.com/hashicorp/terraform-plugin-sdk@v1.13.0/internal/helper/plugin/grpc_provider.go:487 +0x1d2 github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_Configure_Handler({0xd2c5e0?, 0xc000012ba0}, {0xed97a8, 0xc0000f74a0}, 0xc0000be360, 0x0) github.com/hashicorp/terraform-plugin-sdk@v1.13.0/internal/tfplugin5/tfplugin5.pb.go:3251 +0x170 google.golang.org/grpc.(*Server).processUnaryRPC(0xc000002480, {0xedd060, 0xc0001f2000}, 0xc0000c0200, 0xc000097770, 0x13cc738, 0x0) google.golang.org/grpc@v1.27.1/server.go:1024 +0xd4f google.golang.org/grpc.(*Server).handleStream(0xc000002480, {0xedd060, 0xc0001f2000}, 0xc0000c0200, 0x0) google.golang.org/grpc@v1.27.1/server.go:1313 +0xa25 google.golang.org/grpc.(*Server).serveStreams.func1.1() google.golang.org/grpc@v1.27.1/server.go:722 +0x98 created by google.golang.org/grpc.(*Server).serveStreams.func1 google.golang.org/grpc@v1.27.1/server.go:720 +0xea Error: The terraform-provider-gitea_v0.1.0 plugin crashed! ```
lunny added the
bug
label 2023-04-19 06:14:06 +00:00

This error appeared to me because I used a self-signed certificate without Subject Alternative Name.

Until I figured out the problem, I wasted a few hours.

I think it happens with any malformed requests.

This error appeared to me because I used a self-signed certificate without Subject Alternative Name. Until I figured out the problem, I wasted a few hours. I think it happens with any malformed requests.
Contributor

I can not recreate this issue with Gitea 1.20.5. If not specifying the protocol in the gitea url, I get:
Error: Get "gitea.example.com/api/v1/version": unsupported protocol scheme "

If I specify something other than http and https , I get an appropriate error.

If this issue is related the certificate used, then the that issue should be described @wandersonwhcr.

I can not recreate this issue with Gitea 1.20.5. If not specifying the protocol in the gitea url, I get: `Error: Get "gitea.example.com/api/v1/version": unsupported protocol scheme "` If I specify something other than _http_ and _https_ , I get an appropriate error. If this issue is related the certificate used, then the that issue should be described @wandersonwhcr.
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/terraform-provider-gitea#6
No description provided.