[Fix] Fail fast when authenticating if host is not configured#1033
[Fix] Fail fast when authenticating if host is not configured#1033
Conversation
config/config.go
Outdated
| c.credentialsProvider = credentialsProvider | ||
| c.AuthType = c.Credentials.Name() | ||
| c.fixHostIfNeeded() | ||
| if err := c.assertHostIsSet(); err != nil { |
There was a problem hiding this comment.
is this something that we should do inside fixHostIfNeeded()?
There was a problem hiding this comment.
Currently, fixHostIfNeeded is called before Configure() and from other places, and the Configure() credential providers are responsible for populating the host if the user specified an azure workspace resource ID. If we could separate those elements from one another, then we could have the following logic:
- populate host if needed
- fixHostIfNeeded: at this point, host must be set, so it can fail.
- Configure()
However, because fixHostIfNeeded is called from different codepaths, it may not be safe to have this method error if host is not set.
There was a problem hiding this comment.
Actually, fixHostIfNeeded is only called from CanonicalHostname() and this pathway, so I think it is better to do it as you describe. However, we can ignore ErrNoHostConfigured in the first call.
### Bug Fixes * Fail fast when authenticating if host is not configured ([#1033](#1033)). * Improve non-JSON error handling ([#1031](#1031)). ### Internal Changes * Add TestAccCreateOboTokenOnAws to flaky test list ([#1029](#1029)). * Add workflows manage integration tests checks ([#1032](#1032)). * Fix TestMwsAccWorkspaces cleanup ([#1028](#1028)). * Improve integration test comment ([#1035](#1035)). * Temporary ignore Metastore test failures ([#1027](#1027)). * Update test to support new accounts ([#1026](#1026)). * Use statuses instead of checks ([#1036](#1036)). ### API Changes: * Added `RegenerateDashboard` method for [w.QualityMonitors](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#QualityMonitorsAPI) workspace-level service. * Added [catalog.RegenerateDashboardRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#RegenerateDashboardRequest) and [catalog.RegenerateDashboardResponse](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#RegenerateDashboardResponse). * Added [jobs.QueueDetails](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#QueueDetails), [jobs.QueueDetailsCodeCode](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#QueueDetailsCodeCode), [jobs.RunLifecycleStateV2State](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#RunLifecycleStateV2State), [jobs.RunStatus](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#RunStatus), [jobs.TerminationCodeCode](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#TerminationCodeCode), [jobs.TerminationDetails](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#TerminationDetails) and [jobs.TerminationTypeType](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#TerminationTypeType). * Added `Status` field for [jobs.BaseRun](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#BaseRun). * Added `Status` field for [jobs.RepairHistoryItem](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#RepairHistoryItem). * Added `Status` field for [jobs.Run](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#Run). * Added `Status` field for [jobs.RunTask](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#RunTask). * Added `MaxProvisionedThroughput` and `MinProvisionedThroughput` fields for [serving.ServedModelInput](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/serving#ServedModelInput). * Added `ColumnsToSync` field for [vectorsearch.DeltaSyncVectorIndexSpecRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/vectorsearch#DeltaSyncVectorIndexSpecRequest). * Changed `WorkloadSize` field for [serving.ServedModelInput](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/serving#ServedModelInput) to no longer be required. OpenAPI SHA: d05898328669a3f8ab0c2ecee37db2673d3ea3f7, Date: 2024-09-04
### Bug Fixes * Fail fast when authenticating if host is not configured ([#1033](#1033)). * Improve non-JSON error handling ([#1031](#1031)). ### Internal Changes * Add TestAccCreateOboTokenOnAws to flaky test list ([#1029](#1029)). * Add workflows manage integration tests checks ([#1032](#1032)). * Fix TestMwsAccWorkspaces cleanup ([#1028](#1028)). * Improve integration test comment ([#1035](#1035)). * Temporary ignore Metastore test failures ([#1027](#1027)). * Update test to support new accounts ([#1026](#1026)). * Use statuses instead of checks ([#1036](#1036)). ### API Changes: * Added `RegenerateDashboard` method for [w.QualityMonitors](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#QualityMonitorsAPI) workspace-level service. * Added [catalog.RegenerateDashboardRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#RegenerateDashboardRequest) and [catalog.RegenerateDashboardResponse](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/catalog#RegenerateDashboardResponse). * Added [jobs.QueueDetails](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#QueueDetails), [jobs.QueueDetailsCodeCode](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#QueueDetailsCodeCode), [jobs.RunLifecycleStateV2State](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#RunLifecycleStateV2State), [jobs.RunStatus](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#RunStatus), [jobs.TerminationCodeCode](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#TerminationCodeCode), [jobs.TerminationDetails](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#TerminationDetails) and [jobs.TerminationTypeType](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#TerminationTypeType). * Added `Status` field for [jobs.BaseRun](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#BaseRun). * Added `Status` field for [jobs.RepairHistoryItem](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#RepairHistoryItem). * Added `Status` field for [jobs.Run](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#Run). * Added `Status` field for [jobs.RunTask](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/jobs#RunTask). * Added `MaxProvisionedThroughput` and `MinProvisionedThroughput` fields for [serving.ServedModelInput](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/serving#ServedModelInput). * Added `ColumnsToSync` field for [vectorsearch.DeltaSyncVectorIndexSpecRequest](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/vectorsearch#DeltaSyncVectorIndexSpecRequest). * Changed `WorkloadSize` field for [serving.ServedModelInput](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/serving#ServedModelInput) to no longer be required. OpenAPI SHA: d05898328669a3f8ab0c2ecee37db2673d3ea3f7, Date: 2024-09-04
Changes
The SDK currently hangs when making API requests if the Host is set to a non-empty but invalid endpoint, such as
https://:443. This PR adds a check during authentication to ensure that the hostname is defined, failing early if not. The underlying error is exported so other clients, such as the CLI or Terraform Provider, can provide specific advice when this happens.Tests
Added a unit test for this case.
make testpassingmake fmtapplied