Skip to content

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

Merged
vincentkoc merged 3 commits intomainfrom
vincentkoc-code/fix-22836-ollama-config-set
Feb 28, 2026
Merged

fix(cli): allow Ollama apiKey config set without predeclared provider#29299
vincentkoc merged 3 commits intomainfrom
vincentkoc-code/fix-22836-ollama-config-set

Conversation

@vincentkoc
Copy link
Member

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: openclaw config set models.providers.ollama.apiKey "ollama-local" fails validation unless models.providers.ollama.baseUrl and models.providers.ollama.models are already present.
  • Why it matters: this breaks the documented Ollama onboarding path and keeps Ollama auto-discovery fails: schema requires baseUrl+models[] but docs describe apiKey-only env var mode #22836 unresolved.
  • What changed: config set now auto-seeds a valid minimal Ollama provider object when setting models.providers.ollama.apiKey and the provider object does not yet exist.
  • What did NOT change (scope boundary): no model schema/type loosening, no global provider validation changes, no behavior changes for other provider paths.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • openclaw config set models.providers.ollama.apiKey "ollama-local" now writes a valid provider object (with default base URL and empty model list) instead of failing config validation.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node 22 / pnpm
  • Model/provider: Ollama
  • Integration/channel (if any): N/A
  • Relevant config (redacted): empty ~/.openclaw/openclaw.json

Steps

  1. Start with {} config.
  2. Run openclaw config set models.providers.ollama.apiKey "ollama-local".
  3. Inspect written config.

Expected

  • Command succeeds and config remains schema-valid.

Actual

  • Before this change: validation error for missing baseUrl/models.
  • After this change: provider is auto-seeded with valid defaults and command succeeds.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • pnpm vitest run src/cli/config-cli.test.ts
    • pnpm check
    • Manual CLI run with temp HOME writing an empty config, then running openclaw config set models.providers.ollama.apiKey "ollama-local".
  • Edge cases checked:
    • No seeding occurs when setting unrelated paths.
  • What you did not verify:
    • Full onboarding wizard flow end-to-end.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly:
    • Revert this PR.
  • Files/config to restore:
    • src/cli/config-cli.ts
  • Known bad symptoms reviewers should watch for:
    • Unexpected provider object creation on non-Ollama paths.

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk:
    • Over-seeding config for unrelated keys.
    • Mitigation:
      • Guard is path-exact (models.providers.ollama.apiKey) and only runs when provider object is absent.

@openclaw-barnacle openclaw-barnacle bot added cli CLI command changes size: XS maintainer Maintainer-authored PR labels Feb 28, 2026
@vincentkoc vincentkoc marked this pull request as ready for review February 28, 2026 07:29
@aisle-research-bot
Copy link

aisle-research-bot bot commented Feb 28, 2026

🔒 Aisle Security Analysis

✅ We scanned this PR and did not find any security vulnerabilities.

Aisle supplements but does not replace security review.


Analyzed PR: #29299 at commit 562dfb8

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

This PR fixes the documented Ollama onboarding path by auto-seeding a valid minimal provider object when setting models.providers.ollama.apiKey on a fresh config. The implementation is clean and targeted:

  • Adds a path-exact guard that only triggers for models.providers.ollama.apiKey
  • Seeds the provider with correct defaults (baseUrl: "http://127.0.0.1:11434", api: "ollama", models: []) that match autodiscovery behavior
  • Preserves existing provider objects (no over-seeding)
  • Includes appropriate test coverage for the fixed scenario

The fix aligns with the documented Quick Start instructions in docs/providers/ollama.md line 40, which recommends openclaw config set models.providers.ollama.apiKey "ollama-local" as the configuration step.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is well-tested, narrowly scoped to fix a specific documented workflow, and uses correct default values that match existing autodiscovery behavior. The logic is defensive (checks path exactly, verifies provider doesn't exist before seeding) and preserves backward compatibility.
  • No files require special attention

Last reviewed commit: 562dfb8

@vincentkoc vincentkoc merged commit b297bae into main Feb 28, 2026
24 of 27 checks passed
@vincentkoc vincentkoc deleted the vincentkoc-code/fix-22836-ollama-config-set branch February 28, 2026 07:35
vincentkoc added a commit that referenced this pull request Feb 28, 2026
stolyarchuk pushed a commit to llmxio/openclaw that referenced this pull request Feb 28, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
stolyarchuk pushed a commit to llmxio/openclaw that referenced this pull request Feb 28, 2026
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 28, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 28, 2026
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path

(cherry picked from commit d6a87ae)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path

(cherry picked from commit d6a87ae)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path

(cherry picked from commit d6a87ae)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Mar 1, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Mar 1, 2026
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Mar 1, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Mar 1, 2026
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
…penclaw#29579)

(cherry picked from commit 5d51e99)

# Conflicts:
#	CHANGELOG.md
ansh pushed a commit to vibecode/openclaw that referenced this pull request Mar 2, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
ansh pushed a commit to vibecode/openclaw that referenced this pull request Mar 2, 2026
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
safzanpirani pushed a commit to safzanpirani/clawdbot that referenced this pull request Mar 2, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
safzanpirani pushed a commit to safzanpirani/clawdbot that referenced this pull request Mar 2, 2026
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
…penclaw#29579)

(cherry picked from commit 5d51e99)

# Conflicts:
#	CHANGELOG.md
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
sachinkundu pushed a commit to sachinkundu/openclaw that referenced this pull request Mar 6, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
sachinkundu pushed a commit to sachinkundu/openclaw that referenced this pull request Mar 6, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Mateljan1 pushed a commit to Mateljan1/openclaw that referenced this pull request Mar 7, 2026
…openclaw#29299)

* CLI: seed Ollama provider on apiKey set

* Tests: cover Ollama apiKey config set path
Mateljan1 pushed a commit to Mateljan1/openclaw that referenced this pull request Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ollama auto-discovery fails: schema requires baseUrl+models[] but docs describe apiKey-only env var mode

1 participant