nil pointer when orgurl is malformed
monde opened this issue · comments
Describe the bug?
Config nil pointer panic when cfg.Okta.Client.OrgUrl is is malformed.
What is expected to happen?
Graceful validation and failure.
What is the actual behavior?
nil pointer panic
Reproduction Steps?
have malformed org url
Additional Information?
No response
Golang Version
go version go1.21.0 darwin/amd64
SDK Version
Issue template seems to have misinformation.
$ make sdk-version
make: *** No rule to make target `sdk-version'. Stop.
OS version
@duytiennguyen-okta there needs to be some validation or graceful failure in the v3 okta-sdk-golang client if org url is malformed. Here url.Parse is called, but without inspecting the error object:
purl, _ := url.Parse(cfg.Okta.Client.OrgUrl)
https://github.com/okta/okta-sdk-golang/blob/master/.generator/templates/configuration.mustache#L260
The next line cfg.Host = purl.Hostname()
will nil panic if there was a parse error.
Given an org url of "iadf^dfads.okta.com"
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: Plugin did not respond
│
│ with provider["registry.terraform.io/okta/okta"],
│ on main.tf line 14, in provider "okta":
│ 14: provider "okta" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ConfigureProvider call. The plugin logs may contain more details.
╵
Stack trace from the terraform-provider-okta plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x1c796a3]
goroutine 33 [running]:
net/url.(*URL).Hostname(...)
/usr/local/Cellar/go/1.21.0/libexec/src/net/url/url.go:1144
github.com/okta/okta-sdk-golang/v3/okta.NewConfiguration({0xc0002de2a0, 0xc, 0xc0002d11f0?})
/Users/mikemondragon/projects/pkg/mod/github.com/okta/okta-sdk-golang/v3@v3.0.14/okta/configuration.go:196 +0x4a3
github.com/okta/terraform-provider-okta/okta.oktaV3SDKClient(0xc000493680)
Was seeing this in TF: okta/terraform-provider-okta#1712
This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the stale
label.
This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the stale
label.