-
Notifications
You must be signed in to change notification settings - Fork 180
Improve error for labs projects that do not provide labs.yml #5559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package project_test | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "testing" | ||
|
|
||
| "github.com/databricks/cli/cmd/labs/github" | ||
| "github.com/databricks/cli/internal/testcli" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestInstallerFailsForProjectWithoutLabsYml(t *testing.T) { | ||
| server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| if r.URL.Path == "/databrickslabs/blueprint/v0.3.15/labs.yml" { | ||
| w.WriteHeader(http.StatusNotFound) | ||
| return | ||
| } | ||
| t.Logf("Requested: %s", r.URL.Path) | ||
| t.FailNow() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, and it matches the existing pattern in installer_test.go, so fine to leave as is: |
||
| })) | ||
| defer server.Close() | ||
| ctx := installerContext(t, server) | ||
|
|
||
| r := testcli.NewRunner(t, ctx, "labs", "install", "blueprint") | ||
| _, _, err := r.Run() | ||
| assert.ErrorIs(t, err, github.ErrNotFound) | ||
| assert.ErrorContains(t, err, "databrickslabs/blueprint@v0.3.15 does not provide labs.yml") | ||
| assert.ErrorContains(t, err, "cannot be installed with the Databricks CLI") | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch also catches a valid project requested at a version that does not exist, e.g.
labs install blueprint@v9.9.9(right after the "Installing unreleased version" warning). For that case the message is wrong: blueprint does provide labs.yml, the ref is just bad. Consider wording that covers both causes, e.g.labs.yml not found for databrickslabs/%s@%s; either this version does not exist or this project cannot be installed with the Databricks CLI, see ...