fix(cli): allow Ollama apiKey config set without predeclared provider (#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
This commit is contained in:
Vincent Koc
2026-02-27 23:35:57 -08:00
committed by GitHub
parent 7968c0f514
commit b297bae027
2 changed files with 47 additions and 0 deletions

View File

@@ -141,6 +141,24 @@ describe("config cli", () => {
expect(written.gateway?.port).toBe(18789);
expect(written.gateway?.auth).toEqual({ mode: "token" });
});
it("auto-seeds a valid Ollama provider when setting only models.providers.ollama.apiKey", async () => {
const resolved: OpenClawConfig = {
gateway: { port: 18789 },
};
setSnapshot(resolved, resolved);
await runConfigCommand(["config", "set", "models.providers.ollama.apiKey", '"ollama-local"']);
expect(mockWriteConfigFile).toHaveBeenCalledTimes(1);
const written = mockWriteConfigFile.mock.calls[0]?.[0];
expect(written.models?.providers?.ollama).toEqual({
baseUrl: "http://127.0.0.1:11434",
api: "ollama",
models: [],
apiKey: "ollama-local",
});
});
});
describe("config get", () => {