mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-09 16:21:15 +00:00
fix(doctor): add missing baseUrl and models when migrating nano-banana apiKey to google provider
The legacy nano-banana-pro skill migration moves the Gemini API key to models.providers.google.apiKey but does not populate the required baseUrl and models fields on the provider entry. When the google provider object is freshly created (no pre-existing config), the resulting config fails Zod validation on write: Config validation failed: models.providers.google.baseUrl: Invalid input: expected string, received undefined Fix: default baseUrl to 'https://generativelanguage.googleapis.com' and models to [] when they are not already set, matching the defaults used elsewhere in the codebase (embeddings-gemini, pdf-native-providers). Fixes the 'doctor --fix' crash for users who only have a legacy nano-banana-pro skill entry and no existing models.providers.google.
This commit is contained in:
committed by
Peter Steinberger
parent
a1cb302c20
commit
2f238b5d7d
@@ -318,6 +318,10 @@ describe("normalizeCompatibilityConfigValues", () => {
|
||||
provider: "default",
|
||||
id: "GEMINI_API_KEY",
|
||||
});
|
||||
expect(res.config.models?.providers?.google?.baseUrl).toBe(
|
||||
"https://generativelanguage.googleapis.com",
|
||||
);
|
||||
expect(res.config.models?.providers?.google?.models).toEqual([]);
|
||||
expect(res.config.skills?.entries).toBeUndefined();
|
||||
expect(res.changes).toEqual([
|
||||
"Moved skills.entries.nano-banana-pro → agents.defaults.imageGenerationModel.primary (google/gemini-3-pro-image-preview).",
|
||||
@@ -341,6 +345,10 @@ describe("normalizeCompatibilityConfigValues", () => {
|
||||
});
|
||||
|
||||
expect(res.config.models?.providers?.google?.apiKey).toBe("env-gemini-key");
|
||||
expect(res.config.models?.providers?.google?.baseUrl).toBe(
|
||||
"https://generativelanguage.googleapis.com",
|
||||
);
|
||||
expect(res.config.models?.providers?.google?.models).toEqual([]);
|
||||
expect(res.changes).toContain(
|
||||
"Moved skills.entries.nano-banana-pro.env.GEMINI_API_KEY → models.providers.google.apiKey.",
|
||||
);
|
||||
|
||||
@@ -579,6 +579,12 @@ export function normalizeCompatibilityConfigValues(cfg: OpenClawConfig): {
|
||||
const hasGoogleApiKey = rawGoogle.apiKey !== undefined;
|
||||
if (!hasGoogleApiKey && legacyApiKey) {
|
||||
rawGoogle.apiKey = legacyApiKey;
|
||||
if (!rawGoogle.baseUrl) {
|
||||
rawGoogle.baseUrl = "https://generativelanguage.googleapis.com";
|
||||
}
|
||||
if (!Array.isArray(rawGoogle.models)) {
|
||||
rawGoogle.models = [];
|
||||
}
|
||||
rawProviders.google = rawGoogle;
|
||||
rawModels.providers = rawProviders as NonNullable<OpenClawConfig["models"]>["providers"];
|
||||
next = {
|
||||
|
||||
Reference in New Issue
Block a user