Skip to content

Commit 401cca3

Browse files
anton-107Isaac
andcommitted
aitools: do not block plugin installs on the latest-release lookup
Plugin installs no longer fail when the lookup of the latest skills release on api.github.com fails (for example HTTP 403 when rate-limited). The agent's own CLI fetches the plugin from its marketplace, so the skills ref only labels the recorded plugin version. On lookup failure the CLI now records the plugin version as unknown and keeps the scope's existing `state.Release`. ```diff executePlan (cmd/aitools/install.go) if plugin items ref = GetSkillsRef(ctx) - lookup error -> install fails + lookup error -> debug log, ref = "" (plugin version unknown) install plugins RecordPluginInstalls (libs/aitools/installer/plugin.go) - state.Release = ref + if ref != "": state.Release = ref ``` `DATABRICKS_SKILLS_REF` and a pinned compat version still take precedence. Skills installs are unchanged. Changelog fragment: `.nextchanges/cli/aitools-plugin-ref-fallback.md`. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 7123aae commit 401cca3

5 files changed

Lines changed: 76 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* `databricks aitools install` no longer fails a plugin-only install when the lookup of the latest skills release on GitHub fails or is rate-limited. The plugin is installed and its version is recorded as unknown. ([#7474](https://github.com/databricks/cli/pull/7474))

‎cmd/aitools/install.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,12 @@ func executePlan(ctx context.Context, src installer.ManifestSource, plan []agent
588588

589589
pluginCount := 0
590590
if len(pluginItems) > 0 {
591+
// Plugins install from the agent's marketplace, so the skills ref only
592+
// labels the recorded version. Record it as unknown when unresolved.
591593
ref, _, err := installer.GetSkillsRef(ctx)
592594
if err != nil {
593-
return outcomes, err
595+
log.Debugf(ctx, "Recording plugin version as unknown: %v", err)
596+
ref = ""
594597
}
595598
records := map[string]installer.PluginRecord{}
596599
for _, it := range pluginItems {

‎cmd/aitools/install_test.go‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"context"
77
"encoding/json"
88
"errors"
9+
"net/http"
10+
"net/http/httptest"
911
"os"
1012
"path/filepath"
1113
"runtime"
@@ -269,6 +271,52 @@ func TestExecutePlanSkipBlockedPluginExit0(t *testing.T) {
269271
require.Error(t, err)
270272
}
271273

274+
func TestExecutePlanPluginWithUnresolvedSkillsRelease(t *testing.T) {
275+
tmp := t.TempDir()
276+
t.Setenv("DATABRICKS_SKILLS_REF", "")
277+
t.Setenv("DATABRICKS_FORCE_EMBEDDED_COMPAT", "false")
278+
t.Setenv("DATABRICKS_CACHE_ENABLED", "true")
279+
t.Setenv("DATABRICKS_CACHE_DIR", tmp)
280+
require.NoError(t, os.WriteFile(filepath.Join(tmp, "compat-manifest.json"), []byte(`{"0.0.0":{"appkit":"0.84.0","skills":"latest"}}`), 0o600))
281+
lookups := 0
282+
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
283+
lookups++
284+
w.WriteHeader(http.StatusForbidden)
285+
}))
286+
t.Cleanup(srv.Close)
287+
t.Setenv("DATABRICKS_CLI_GITHUB_API_URL", srv.URL)
288+
289+
installRef, recordRef := "unset", "unset"
290+
orig := installPluginForAgentFn
291+
origRec := recordPluginInstallsFn
292+
origCleanup := cleanupLegacyFn
293+
t.Cleanup(func() {
294+
installPluginForAgentFn = orig
295+
recordPluginInstallsFn = origRec
296+
cleanupLegacyFn = origCleanup
297+
})
298+
cleanupLegacyFn = func(context.Context, *agents.Agent, string) error { return nil }
299+
installPluginForAgentFn = func(_ context.Context, _ *agents.Agent, scope, ref string) (installer.PluginRecord, error) {
300+
installRef = ref
301+
return installer.PluginRecord{Plugin: "databricks", Scope: scope, Version: installer.DisplaySkillsVersion(ref)}, nil
302+
}
303+
recordPluginInstallsFn = func(_ context.Context, _ string, _ map[string]installer.PluginRecord, ref string) error {
304+
recordRef = ref
305+
return nil
306+
}
307+
308+
claude := testPluginAgent(agents.NameClaudeCode, "Claude Code", "claude")
309+
plan := buildPlan([]*agents.Agent{claude}, installer.ScopeGlobal, false, true)
310+
outcomes, err := executePlan(cmdio.MockDiscard(t.Context()), nil, plan, installer.InstallOptions{Scope: installer.ScopeGlobal}, false)
311+
require.NoError(t, err)
312+
require.Len(t, outcomes, 1)
313+
assert.Equal(t, outcomeInstalled, outcomes[0].status)
314+
assert.Equal(t, 1, lookups)
315+
// The marketplace picks the plugin version, so a failed lookup records it as unknown.
316+
assert.Empty(t, installRef)
317+
assert.Empty(t, recordRef)
318+
}
319+
272320
// --- RunE: skills-only path (config-dir detection, no plugin) ---
273321

274322
func TestInstallSkillsOnlyAllAgents(t *testing.T) {

‎libs/aitools/installer/plugin.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,10 @@ func RecordPluginInstalls(ctx context.Context, cliScope string, records map[stri
415415
state.Plugins = make(map[string]PluginRecord, len(records))
416416
}
417417
maps.Copy(state.Plugins, records)
418-
state.Release = ref
418+
// An unresolved release keeps the one recorded by earlier installs.
419+
if ref != "" {
420+
state.Release = ref
421+
}
419422
state.LastUpdated = time.Now()
420423
state.Scope = cliScope
421424
return SaveState(dir, state)

‎libs/aitools/installer/plugin_test.go‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,25 @@ func TestUninstallPluginKeepMarketplaceFlag(t *testing.T) {
771771
}
772772
}
773773

774+
func TestRecordPluginInstallsUnresolvedRefKeepsRelease(t *testing.T) {
775+
setupTestHome(t)
776+
ctx := cmdio.MockDiscard(t.Context())
777+
dir, err := GlobalSkillsDir(ctx)
778+
require.NoError(t, err)
779+
780+
require.NoError(t, RecordPluginInstalls(ctx, ScopeGlobal, map[string]PluginRecord{
781+
agents.NameClaudeCode: {Marketplace: "databricks-agent-skills", Plugin: "databricks", Version: "0.2.6"},
782+
}, "v0.2.6"))
783+
require.NoError(t, RecordPluginInstalls(ctx, ScopeGlobal, map[string]PluginRecord{
784+
agents.NameCodex: {Marketplace: "databricks-agent-skills", Plugin: "databricks"},
785+
}, ""))
786+
787+
st, err := LoadState(dir)
788+
require.NoError(t, err)
789+
assert.Equal(t, "v0.2.6", st.Release)
790+
assert.Contains(t, st.Plugins, agents.NameCodex)
791+
}
792+
774793
func TestRecordPluginInstallsThenSkillsInstallNoPanic(t *testing.T) {
775794
tmp := setupTestHome(t)
776795
ctx := cmdio.MockDiscard(t.Context())

0 commit comments

Comments
 (0)