Skip to content

Commit 45afed3

Browse files
authored
Remove unused experimental aitools helpers (#4733)
## Summary - remove the unused `experimental/aitools` detector, pathutil, and prompts packages - inline the auth error formatter in middleware and add focused coverage for the rendered message - trim the session package down to the context and key-value helpers still used by live aitools commands ## Test plan - [x] `go test ./experimental/aitools/...`
1 parent f121e12 commit 45afed3

File tree

12 files changed

+85
-863
lines changed

12 files changed

+85
-863
lines changed

experimental/aitools/lib/detector/bundle_detector.go

Lines changed: 0 additions & 67 deletions
This file was deleted.

experimental/aitools/lib/detector/detector.go

Lines changed: 0 additions & 58 deletions
This file was deleted.

experimental/aitools/lib/detector/detector_test.go

Lines changed: 0 additions & 131 deletions
This file was deleted.

experimental/aitools/lib/detector/template_detector.go

Lines changed: 0 additions & 74 deletions
This file was deleted.

experimental/aitools/lib/middlewares/databricks_client.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package middlewares
33
import (
44
"context"
55
"errors"
6+
"fmt"
7+
"strings"
68

7-
"github.com/databricks/cli/experimental/aitools/lib/prompts"
89
"github.com/databricks/cli/experimental/aitools/lib/session"
910
"github.com/databricks/cli/libs/databrickscfg/profile"
1011
"github.com/databricks/databricks-sdk-go"
@@ -37,9 +38,20 @@ func GetDatabricksClient(ctx context.Context) (*databricks.WorkspaceClient, erro
3738
}
3839

3940
func newAuthError(ctx context.Context) error {
40-
// Prepare template data
41-
data := map[string]any{
42-
"Profiles": GetAvailableProfiles(ctx),
41+
return errors.New(formatAuthError(GetAvailableProfiles(ctx)))
42+
}
43+
44+
func formatAuthError(profiles profile.Profiles) string {
45+
var b strings.Builder
46+
b.WriteString("Not authenticated to Databricks\n\n")
47+
b.WriteString("I need to know either the Databricks workspace URL or the Databricks profile name.\n\n")
48+
b.WriteString("The available profiles are:\n\n")
49+
for _, p := range profiles {
50+
fmt.Fprintf(&b, "- %s (%s)\n", p.Name, p.Host)
4351
}
44-
return errors.New(prompts.MustExecuteTemplate("auth_error.tmpl", data))
52+
b.WriteString("\n")
53+
b.WriteString("IMPORTANT: YOU MUST ASK the user which of the configured profiles or databricks workspace URL they want to use.\n")
54+
b.WriteString("Then set the DATABRICKS_HOST and DATABRICKS_TOKEN environment variables, or use a named profile via DATABRICKS_CONFIG_PROFILE.\n\n")
55+
b.WriteString("Do not run anything else before authenticating successfully.\n")
56+
return b.String()
4557
}

0 commit comments

Comments
 (0)