Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `databricks aitools install --output json` reports more specific `error_category` values: `SKILLS_FETCH_FAILED`, `RELEASE_LOOKUP_FAILED`, `RATE_LIMITED`, `MANIFEST_INVALID`, `STATE_INVALID` and `PLUGIN_CLI_TIMEOUT`. A coding agent CLI that does not answer in time is now reported as `timed out after <duration>`, followed by any stderr it wrote before it was stopped. ([#7475](https://github.com/databricks/cli/pull/7475))
6 changes: 3 additions & 3 deletions acceptance/cmd/aitools/telemetry/install-failure/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Error: skills manifest at databricks-agent-skills@missing-ref: not found
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"MANIFEST_NOT_FOUND","interactive":false,"install_mode":"SKILLS_ONLY","agents":["CURSOR"],"scope":"GLOBAL"}}
{"command":"aitools_install","exit_code":1,"aitools_install_event":{"agents":["CURSOR"],"scope":"GLOBAL","error_category":"MANIFEST_NOT_FOUND"}}

=== any other HTTP error status from the manifest fetch is not classified yet (the error is untyped)
=== any other HTTP error status from the manifest fetch is SKILLS_FETCH_FAILED

>>> DATABRICKS_SKILLS_REF=broken-ref [CLI] aitools install --skills-only --scope=global --agents=cursor
Installing Databricks skills for Cursor...
Expand All @@ -47,8 +47,8 @@ Error: failed to fetch manifest: HTTP 500
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"SCOPE_RESOLVED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"AGENTS_SELECTED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"PLAN_CONFIRMED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"UNCATEGORIZED","interactive":false,"install_mode":"SKILLS_ONLY","agents":["CURSOR"],"scope":"GLOBAL"}}
{"command":"aitools_install","exit_code":1,"aitools_install_event":{"agents":["CURSOR"],"scope":"GLOBAL","error_category":"UNCATEGORIZED"}}
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"SKILLS_FETCH_FAILED","interactive":false,"install_mode":"SKILLS_ONLY","agents":["CURSOR"],"scope":"GLOBAL"}}
{"command":"aitools_install","exit_code":1,"aitools_install_event":{"agents":["CURSOR"],"scope":"GLOBAL","error_category":"SKILLS_FETCH_FAILED"}}

=== a named agent skipped for the scope takes its category from the agent's outcome

Expand Down
2 changes: 1 addition & 1 deletion acceptance/cmd/aitools/telemetry/install-failure/script
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ title "a manifest the server does not have is MANIFEST_NOT_FOUND"
musterr trace DATABRICKS_SKILLS_REF=missing-ref $CLI aitools install --skills-only --scope=global --agents=cursor
trace print_telemetry

title "any other HTTP error status from the manifest fetch is not classified yet (the error is untyped)"
title "any other HTTP error status from the manifest fetch is SKILLS_FETCH_FAILED"
musterr trace DATABRICKS_SKILLS_REF=broken-ref $CLI aitools install --skills-only --scope=global --agents=cursor
trace print_telemetry

Expand Down
64 changes: 59 additions & 5 deletions cmd/aitools/categorize.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aitools

import (
"context"
"encoding/json"
"errors"
"io/fs"
"net"
Expand Down Expand Up @@ -57,6 +58,14 @@ func classifyInstallError(err error) protos.AitoolsErrorCategory {
if skill, ok := errors.AsType[*installer.SkillError](err); ok {
return skillErrorCategory(skill)
}
// FetchError is checked before the standard library types: a response
// that arrived carries a status the net error types know nothing about.
if fetch, ok := errors.AsType[*installer.FetchError](err); ok {
Comment on lines +61 to +63

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] The comment above these categories in libs/telemetry/protos/aitools_install.go:55-56 says "The typed installer errors (release lookup, skills fetch) win over the generic network/timeout classification." With this PR it is the other way round: a FetchError with a transport cause reports NETWORK or TIMEOUT, and the typed categories apply only once a response arrived. Someone reading the enum would expect every failed release lookup to be RELEASE_LOOKUP_FAILED. Update that comment to match.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 57c5e35. The comment above the fetch categories in libs/telemetry/protos/aitools_install.go now says that a fetch failing on the transport (no response, or a timeout or reset while reading the body) reports NETWORK or TIMEOUT, and the other categories apply once a response arrived.

return fetchErrorCategory(fetch)
}
if _, ok := errors.AsType[*installer.StateError](err); ok {
return protos.AitoolsErrorCategoryStateInvalid
}
if tagged, ok := errors.AsType[*categorizedError](err); ok {
return tagged.category
}
Expand All @@ -71,11 +80,11 @@ func classifyInstallError(err error) protos.AitoolsErrorCategory {
}

// stdlibErrorCategory classifies errors by their standard library type, which
// the installer wraps with %w: network and timeout errors from fetching the
// manifest or skill files, and filesystem errors from writing skills or the
// install state. JSON decode errors stay UNCATEGORIZED: the manifest, the
// release payload and the install state all decode JSON, so only typed
// installer errors can tell MANIFEST_INVALID from STATE_INVALID.
// the installer wraps with %w: filesystem errors from writing skills or the
// install state, and network and timeout errors, including those of a
// FetchError that got no response. JSON decode errors stay UNCATEGORIZED: the
// manifest, the release payload and the install state all decode JSON, so only
// typed installer errors can tell MANIFEST_INVALID from STATE_INVALID.
func stdlibErrorCategory(err error) protos.AitoolsErrorCategory {
switch {
case errors.Is(err, huh.ErrUserAborted):
Expand Down Expand Up @@ -133,7 +142,52 @@ func skillErrorCategory(e *installer.SkillError) protos.AitoolsErrorCategory {
}
}

// fetchErrorCategory maps a FetchError to its category. The first matching
// case wins, so the order matters: an interrupted command is never a fetch
// failure, a transport failure keeps its NETWORK or TIMEOUT category, and the
// release stage is checked before the decode check.
func fetchErrorCategory(e *installer.FetchError) protos.AitoolsErrorCategory {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] .agents/rules/comments.md asks for a doc comment on Go functions, and this switch depends on its order: cancel, then rate limit, then not-found, then release stage, then decode. A one-line doc saying the first matching case wins, and why the release stage comes before the decode check, would stop a later reorder from silently changing categories.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in af32385: a doc comment on fetchErrorCategory saying that the first matching case wins and explaining the order (interrupted, then no response, then the release stage before the decode check).

// The command was interrupted while the request was in flight: the fetch
// did not fail on its own.
if errors.Is(e, context.Canceled) {
return protos.AitoolsErrorCategoryCommandInterrupted
}
// No response arrived (DNS, refused connection, proxy, TLS, client
// timeout), or reading the body failed on the transport (a timeout or a
// reset mid-body): the user cannot reach the host, which NETWORK and
// TIMEOUT already report.
if c := stdlibErrorCategory(e.Err); e.StatusCode == 0 || c == protos.AitoolsErrorCategoryNetwork || c == protos.AitoolsErrorCategoryTimeout {
return c
}
switch {
case e.RateLimited:
return protos.AitoolsErrorCategoryRateLimited
case errors.Is(e, clicompat.ErrNotFound):
return protos.AitoolsErrorCategoryManifestNotFound
// Before the decode check: a release payload that does not decode is a
// failed release lookup, not an invalid manifest.
case e.Stage == installer.FetchStageRelease:
return protos.AitoolsErrorCategoryReleaseLookupFailed
// The response arrived but was not a manifest: content, not transport.
case isManifestDecodeError(e) || errors.Is(e, installer.ErrManifestTooLarge):
return protos.AitoolsErrorCategoryManifestInvalid
default:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] Every installer fetch now wraps its transport error in FetchError (source.go:37, installer.go:163, installer.go:255), and fetchErrorCategory has no transport case. A DNS failure, a refused connection or the 30s client timeout now all report SKILLS_FETCH_FAILED / RELEASE_LOOKUP_FAILED, the same as a GitHub 500 (funnel_test.go:334/374 show a refused connection moving from NETWORK to SKILLS_FETCH_FAILED). In both telemetry and the --output json error_category that shipped in v1.25.0, "the user can't reach GitHub" can no longer be told apart from "GitHub failed", and a script that retries on NETWORK/TIMEOUT silently stops matching. Merge Danger mentions NETWORK but not TIMEOUT, and lists the blast radius as telemetry-only. Either classify a FetchError with StatusCode == 0 through stdlibErrorCategory(e.Err) (after the Canceled check) to keep NETWORK/TIMEOUT, or say in the changelog fragment and Merge Danger that these failures no longer report NETWORK/TIMEOUT in --output json.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in af32385: fetchErrorCategory now sends a FetchError with StatusCode == 0 (no response arrived) through stdlibErrorCategory, right after the Canceled check. So DNS failures and refused connections report NETWORK again, and client timeouts report TIMEOUT, the same as the released --output json contract. The specific categories now only apply to fetches that got a response. funnel_test.go is back to NETWORK for the refused connection. I added cases for a release lookup with no response (NETWORK), a manifest refused connection (NETWORK) and a skill file timeout (TIMEOUT). I also updated the changelog fragment and the Merge Danger section to match.

return protos.AitoolsErrorCategorySkillsFetchFailed
}
}

// isManifestDecodeError reports whether the response arrived but was not a
// valid manifest.
func isManifestDecodeError(err error) bool {
_, syntax := errors.AsType[*json.SyntaxError](err)
_, typ := errors.AsType[*json.UnmarshalTypeError](err)
return syntax || typ
}

func blockedErrorCategory(e *installer.BlockedError) protos.AitoolsErrorCategory {
if e.TimedOut {
return protos.AitoolsErrorCategoryPluginCLITimeout
}
switch e.Reason {
case installer.ReasonCLINotOnPath:
return protos.AitoolsErrorCategoryCLINotOnPath
Expand Down
175 changes: 166 additions & 9 deletions cmd/aitools/categorize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import (
"fmt"
"io/fs"
"net"
"net/http"
"net/http/httptest"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"syscall"
"testing"
"time"

"github.com/charmbracelet/huh"
"github.com/databricks/cli/libs/aitools/installer"
Expand Down Expand Up @@ -42,6 +47,66 @@ func TestClassifyInstallError(t *testing.T) {
err: &installer.BlockedError{Agent: "codex", Reason: installer.ReasonInstallFailed},
want: protos.AitoolsErrorCategoryPluginInstallFailed,
},
{
name: "blocked timeout wins over its reason",
err: &installer.BlockedError{Agent: "claude-code", Reason: installer.ReasonCLINotOnPath, TimedOut: true},
want: protos.AitoolsErrorCategoryPluginCLITimeout,
},
{
name: "release lookup failed",
err: fmt.Errorf("resolve latest skills release: %w", &installer.FetchError{Stage: installer.FetchStageRelease, StatusCode: 500, Err: errors.New("HTTP 500 fetching latest skills release")}),
want: protos.AitoolsErrorCategoryReleaseLookupFailed,
},
{
name: "release lookup with no response is NETWORK",
err: fmt.Errorf("resolve latest skills release: %w", &installer.FetchError{Stage: installer.FetchStageRelease, Err: &url.Error{Op: "Get", URL: "https://example.test", Err: &net.DNSError{Err: "no such host"}}}),
want: protos.AitoolsErrorCategoryNetwork,
},
{
name: "release payload that does not decode is not an invalid manifest",
err: &installer.FetchError{Stage: installer.FetchStageRelease, StatusCode: 200, Err: fmt.Errorf("parse latest skills release: %w", &json.SyntaxError{})},
want: protos.AitoolsErrorCategoryReleaseLookupFailed,
},
{
name: "release lookup rate limited",
err: &installer.FetchError{Stage: installer.FetchStageRelease, StatusCode: 403, RateLimited: true, Err: errors.New("HTTP 403")},
want: protos.AitoolsErrorCategoryRateLimited,
},
{
name: "release lookup denied without rate-limit evidence",
err: &installer.FetchError{Stage: installer.FetchStageRelease, StatusCode: 403, Err: errors.New("HTTP 403")},
want: protos.AitoolsErrorCategoryReleaseLookupFailed,
},
{
name: "manifest fetch rate limited",
err: &installer.FetchError{Stage: installer.FetchStageManifest, StatusCode: 429, RateLimited: true, Err: errors.New("HTTP 429")},
want: protos.AitoolsErrorCategoryRateLimited,
},
{
name: "manifest fetch with no response is NETWORK",
err: &installer.FetchError{Stage: installer.FetchStageManifest, Err: fmt.Errorf("failed to fetch manifest: %w", &url.Error{Op: "Get", URL: "https://example.test", Err: &net.OpError{Op: "dial", Net: "tcp", Err: os.NewSyscallError("connect", syscall.ECONNREFUSED)}})},
want: protos.AitoolsErrorCategoryNetwork,
},
{
name: "skill file fetch that timed out is TIMEOUT",
err: &installer.FetchError{Stage: installer.FetchStageFile, Err: &url.Error{Op: "Get", URL: "https://example.test", Err: os.ErrDeadlineExceeded}},
want: protos.AitoolsErrorCategoryTimeout,
},
{
name: "skill file fetch failed",
err: fmt.Errorf("failed to fetch skills/x/SKILL.md: %w", &installer.FetchError{Stage: installer.FetchStageFile, StatusCode: 500, Err: errors.New("HTTP 500")}),
want: protos.AitoolsErrorCategorySkillsFetchFailed,
},
{
name: "manifest missing at the pinned ref",
err: &installer.FetchError{Stage: installer.FetchStageManifest, StatusCode: 404, Err: fmt.Errorf("skills manifest at x@v9: %w", clicompat.ErrNotFound)},
want: protos.AitoolsErrorCategoryManifestNotFound,
},
{
name: "state file invalid",
err: fmt.Errorf("failed to load install state: %w", &installer.StateError{Path: "/s/.state.json", Err: errors.New("failed to parse state file")}),
want: protos.AitoolsErrorCategoryStateInvalid,
},
{
name: "blocked error with unknown reason is uncategorized",
err: &installer.BlockedError{Agent: "codex", Reason: "some-future-reason"},
Expand Down Expand Up @@ -102,12 +167,12 @@ func TestClassifyInstallErrorGenericCauses(t *testing.T) {
err error
want protos.AitoolsErrorCategory
}{
{"network", fmt.Errorf("failed to fetch manifest: %w", urlErr), protos.AitoolsErrorCategoryNetwork},
{"network", fmt.Errorf("fetch: %w", urlErr), protos.AitoolsErrorCategoryNetwork},
// The shape net/http returns for a refused connection: the Errno sits under the network types.
{"network errno", fmt.Errorf("failed to fetch manifest: %w", &url.Error{Op: "Get", URL: "https://example.test", Err: &net.OpError{Op: "dial", Net: "tcp", Err: os.NewSyscallError("connect", syscall.ECONNREFUSED)}}), protos.AitoolsErrorCategoryNetwork},
{"network errno", fmt.Errorf("fetch: %w", &url.Error{Op: "Get", URL: "https://example.test", Err: &net.OpError{Op: "dial", Net: "tcp", Err: os.NewSyscallError("connect", syscall.ECONNREFUSED)}}), protos.AitoolsErrorCategoryNetwork},
// A sandbox that blocks outbound sockets: a network failure, even though the Errno is EACCES.
{"network permission denied", fmt.Errorf("failed to fetch manifest: %w", &url.Error{Op: "Get", URL: "https://example.test", Err: &net.OpError{Op: "dial", Net: "tcp", Err: os.NewSyscallError("connect", syscall.EACCES)}}), protos.AitoolsErrorCategoryNetwork},
{"network timeout", fmt.Errorf("failed to fetch manifest: %w", &url.Error{Op: "Get", URL: "https://example.test", Err: os.ErrDeadlineExceeded}), protos.AitoolsErrorCategoryTimeout},
{"network permission denied", fmt.Errorf("fetch: %w", &url.Error{Op: "Get", URL: "https://example.test", Err: &net.OpError{Op: "dial", Net: "tcp", Err: os.NewSyscallError("connect", syscall.EACCES)}}), protos.AitoolsErrorCategoryNetwork},
{"network timeout", fmt.Errorf("fetch: %w", &url.Error{Op: "Get", URL: "https://example.test", Err: os.ErrDeadlineExceeded}), protos.AitoolsErrorCategoryTimeout},
{"deadline", fmt.Errorf("fetch: %w", context.DeadlineExceeded), protos.AitoolsErrorCategoryTimeout},
{"cancelled", fmt.Errorf("fetch: %w", context.Canceled), protos.AitoolsErrorCategoryCommandInterrupted},
{"cancelled request", &url.Error{Op: "Get", URL: "https://example.test", Err: context.Canceled}, protos.AitoolsErrorCategoryCommandInterrupted},
Expand Down Expand Up @@ -144,15 +209,14 @@ func TestWithCategoryKeepsMessage(t *testing.T) {
assert.ErrorIs(t, err, cause)
}

// A corrupt install state must not be blamed on the remote manifest. It stays
// UNCATEGORIZED until the installer returns a typed state error, which should
// change this to STATE_INVALID.
func TestClassifyInstallErrorCorruptStateIsUncategorized(t *testing.T) {
// A corrupt install state must not be blamed on the remote manifest: the
// installer's typed StateError makes it STATE_INVALID.
func TestClassifyInstallErrorCorruptStateIsStateInvalid(t *testing.T) {
dir := t.TempDir()
require.NoError(t, os.WriteFile(filepath.Join(dir, ".state.json"), []byte("{not json"), 0o600))
_, err := installer.LoadState(dir)
require.Error(t, err)
assert.Equal(t, protos.AitoolsErrorCategoryUncategorized, classifyInstallError(fmt.Errorf("failed to load install state: %w", err)))
assert.Equal(t, protos.AitoolsErrorCategoryStateInvalid, classifyInstallError(fmt.Errorf("failed to load install state: %w", err)))
}

// readMissingFile returns the error the OS gives for a missing file, so the
Expand All @@ -163,3 +227,96 @@ func readMissingFile(t *testing.T) error {
require.Error(t, err)
return err
}

func TestClassifyCancelledManifestFetchIsCommandInterrupted(t *testing.T) {
ctx, cancel := context.WithCancel(t.Context())
server := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
// Cancel while the request is in flight, then wait for the client to give up.
cancel()
<-r.Context().Done()
}))
t.Cleanup(server.Close)
t.Setenv("DATABRICKS_SKILLS_BASE_URL", server.URL)

_, err := (&installer.GitHubManifestSource{}).FetchManifest(ctx, "v1")
require.ErrorIs(t, err, context.Canceled)
assert.Equal(t, protos.AitoolsErrorCategoryCommandInterrupted, classifyInstallError(err))
}

// A response whose body stalls or is cut off by a reset is a transport
// failure, not a failed fetch: it keeps TIMEOUT or NETWORK.
func TestClassifyManifestBodyTransportFailure(t *testing.T) {
t.Run("stalled body", func(t *testing.T) {
release := make(chan struct{})
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Length", "100")
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte(`{"skills":`))
w.(http.Flusher).Flush()
select {
case <-release:
case <-r.Context().Done():
}
}))
t.Cleanup(server.Close)
t.Cleanup(func() { close(release) })
t.Setenv("DATABRICKS_SKILLS_BASE_URL", server.URL)

ctx, cancel := context.WithTimeout(t.Context(), 200*time.Millisecond)
defer cancel()
_, err := (&installer.GitHubManifestSource{}).FetchManifest(ctx, "v1")
require.Error(t, err)
assert.Equal(t, protos.AitoolsErrorCategoryTimeout, classifyInstallError(err))
})

t.Run("reset mid-body", func(t *testing.T) {
err := &installer.FetchError{Stage: installer.FetchStageManifest, StatusCode: http.StatusOK, Err: fmt.Errorf("failed to read manifest: %w", &net.OpError{Op: "read", Net: "tcp", Err: os.NewSyscallError("read", syscall.ECONNRESET)})}
assert.Equal(t, protos.AitoolsErrorCategoryNetwork, classifyInstallError(err))
})

t.Run("release body timeout", func(t *testing.T) {
err := &installer.FetchError{Stage: installer.FetchStageRelease, StatusCode: http.StatusOK, Err: fmt.Errorf("parse latest skills release: %w", os.ErrDeadlineExceeded)}
assert.Equal(t, protos.AitoolsErrorCategoryTimeout, classifyInstallError(err))
})
}

func TestClassifyRealManifestFetchErrors(t *testing.T) {
tests := []struct {
name string
status int
body string
// cutOff announces a longer body than is sent, so the connection
// closes mid-body.
cutOff bool
want protos.AitoolsErrorCategory
}{
// A captive portal or broken mirror answers 200 with something else.
{name: "200 with HTML", status: http.StatusOK, body: "<html>login</html>", want: protos.AitoolsErrorCategoryManifestInvalid},
{name: "200 with the wrong JSON shape", status: http.StatusOK, body: `{"skills": []}`, want: protos.AitoolsErrorCategoryManifestInvalid},
{name: "200 with an empty body", status: http.StatusOK, body: "", want: protos.AitoolsErrorCategoryManifestInvalid},
{name: "200 with incomplete JSON", status: http.StatusOK, body: `{"skills":`, want: protos.AitoolsErrorCategoryManifestInvalid},
// A body over 1 MiB is not parsed: it is reported as too large, in the
// same category as a manifest that does not parse.
{name: "200 with a body over the size cap", status: http.StatusOK, body: strings.Repeat(" ", 1<<20) + "{}", want: protos.AitoolsErrorCategoryManifestInvalid},
{name: "connection closed mid-body", status: http.StatusOK, body: `{"skills":`, cutOff: true, want: protos.AitoolsErrorCategorySkillsFetchFailed},
{name: "404", status: http.StatusNotFound, want: protos.AitoolsErrorCategoryManifestNotFound},
{name: "503", status: http.StatusServiceUnavailable, want: protos.AitoolsErrorCategorySkillsFetchFailed},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
if tc.cutOff {
w.Header().Set("Content-Length", strconv.Itoa(len(tc.body)+100))
}
w.WriteHeader(tc.status)
_, _ = w.Write([]byte(tc.body))
}))
t.Cleanup(server.Close)
t.Setenv("DATABRICKS_SKILLS_BASE_URL", server.URL)

_, err := (&installer.GitHubManifestSource{}).FetchManifest(t.Context(), "v1")
require.Error(t, err)
assert.Equal(t, tc.want, classifyInstallError(err))
})
}
}
Loading
Loading