mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-08 17:56:14 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2799cd0280 |
No files matched your search
@@ -619,7 +619,15 @@ func (m model) normalizeProfileForProvider(provider providercatalog.Descriptor)
|
||||
strings.TrimSpace(profile.Name) == "" ||
|
||||
strings.TrimSpace(profile.CatalogID) == ""
|
||||
if normalizeIdentity {
|
||||
profile.Name = provider.ID
|
||||
// Only canonicalize an empty or generic placeholder name — never clobber a
|
||||
// real user-provided profile name. The credential store is keyed by
|
||||
// profile.Name (SecureProviderProfile stores under Name), so rewriting it
|
||||
// here made the later profileWithCredential lookup miss the saved key and
|
||||
// rebuild a keyless provider — a 401 on every /model switch for any profile
|
||||
// named differently from its catalog id (e.g. "my-openai").
|
||||
if strings.TrimSpace(profile.Name) == "" || genericProviderCatalogID(profile.Name) {
|
||||
profile.Name = provider.ID
|
||||
}
|
||||
profile.CatalogID = provider.ID
|
||||
}
|
||||
if strings.TrimSpace(profile.BaseURL) == "" {
|
||||
|
||||
@@ -976,3 +976,49 @@ func TestSwitchProviderModelWarmsDiscoveryForTheNewProvider(t *testing.T) {
|
||||
t.Fatal("switching to ollama should warm both the generic and ollama-specific discovery commands")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeProfileForProviderPreservesCustomName(t *testing.T) {
|
||||
openai, ok := providercatalog.Get("openai")
|
||||
if !ok {
|
||||
t.Fatal("openai descriptor missing from catalog")
|
||||
}
|
||||
|
||||
// A first-party provider set up with a custom profile name and the baseURL at
|
||||
// the catalog default. normalizeIdentity is true here (baseURL matches), but
|
||||
// the real name must survive: it is the credential-store key, so clobbering it
|
||||
// dropped the saved key and 401'd every /model switch (issue #440).
|
||||
m := model{providerProfile: config.ProviderProfile{
|
||||
Name: "my-openai",
|
||||
CatalogID: "openai",
|
||||
BaseURL: openai.DefaultBaseURL,
|
||||
APIKeyStored: true,
|
||||
}}
|
||||
got := m.normalizeProfileForProvider(openai)
|
||||
if got.Name != "my-openai" {
|
||||
t.Fatalf("Name = %q, want it preserved as %q (credential store is keyed by Name)", got.Name, "my-openai")
|
||||
}
|
||||
if got.CatalogID != "openai" {
|
||||
t.Fatalf("CatalogID = %q, want it canonicalized to %q", got.CatalogID, "openai")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeProfileForProviderCanonicalizesPlaceholderName(t *testing.T) {
|
||||
openai, ok := providercatalog.Get("openai")
|
||||
if !ok {
|
||||
t.Fatal("openai descriptor missing from catalog")
|
||||
}
|
||||
|
||||
// Empty and generic placeholder names still get canonicalized to the catalog
|
||||
// id — those carry no meaningful credential-store key to preserve.
|
||||
for _, name := range []string{"", "custom-openai-compatible"} {
|
||||
m := model{providerProfile: config.ProviderProfile{
|
||||
Name: name,
|
||||
BaseURL: openai.DefaultBaseURL,
|
||||
CatalogID: name,
|
||||
}}
|
||||
got := m.normalizeProfileForProvider(openai)
|
||||
if got.Name != "openai" {
|
||||
t.Fatalf("Name = %q for placeholder %q, want canonicalized to %q", got.Name, name, "openai")
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -24,8 +24,7 @@
|
||||
"os": [
|
||||
"linux",
|
||||
"darwin",
|
||||
"win32",
|
||||
"android"
|
||||
"win32"
|
||||
],
|
||||
"cpu": [
|
||||
"x64",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// Env overrides (testing / mirrors / locked-down installs):
|
||||
// ZERO_SKIP_DOWNLOAD=1 skip entirely, exit 0 (wrapper will guide if run)
|
||||
// ZERO_INSTALL_DRY_RUN=1 print the resolved plan as JSON, no network, exit 0
|
||||
// ZERO_INSTALL_PLATFORM=… override process.platform (linux|darwin|win32|android)
|
||||
// ZERO_INSTALL_PLATFORM=… override process.platform (linux|darwin|win32)
|
||||
// ZERO_INSTALL_ARCH=… override process.arch (x64|arm64)
|
||||
// ZERO_REPO=owner/name override the GitHub repo (default Gitlawb/zero)
|
||||
// ZERO_GITHUB_BASE_URL=… override the download host (default https://github.com)
|
||||
@@ -65,7 +65,6 @@ function warnSkip(message) {
|
||||
function resolvePlatform(p) {
|
||||
switch (p) {
|
||||
case 'linux':
|
||||
case 'android':
|
||||
return 'linux';
|
||||
case 'darwin':
|
||||
return 'macos';
|
||||
|
||||
Reference in new issue
Block a user