Skip to content

fix(doctor): preserve valid google provider shape in nano-banana migration#53841

Open
eulicesl wants to merge 2 commits intoopenclaw:mainfrom
eulicesl:upstream/fix-doctor-google-provider-defaults
Open

fix(doctor): preserve valid google provider shape in nano-banana migration#53841
eulicesl wants to merge 2 commits intoopenclaw:mainfrom
eulicesl:upstream/fix-doctor-google-provider-defaults

Conversation

@eulicesl
Copy link
Copy Markdown

@eulicesl eulicesl commented Mar 24, 2026

Summary

  • Problem: openclaw doctor --fix could migrate legacy skills.entries.nano-banana-pro config into an invalid models.providers.google object.
  • Why it matters: the migration wrote apiKey only, then config validation failed because ModelProviderSchema requires baseUrl and models.
  • What changed: the nano-banana migration now fills missing google.baseUrl and google.models when it introduces the google provider entry.
  • What did NOT change (scope boundary): no broader provider normalization/refactor; existing explicit native google config is preserved.
  • AI-assisted: yes (prepared with Codex/OpenClaw assistance).
  • Testing level: lightly tested but targeted to the affected migration path.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • 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

Root Cause / Regression History (if applicable)

  • Root cause: normalizeCompatibilityConfigValues() migrated legacy nano-banana config into models.providers.google.apiKey but did not materialize the rest of the required ModelProviderSchema shape.
  • Missing detection / guardrail: there was no regression test asserting that the migrated google provider entry is schema-valid when created from legacy nano-banana config alone.
  • Prior context (git blame, prior PR, issue, or refactor if known): reported in doctor --fix crashes with Config validation failed on models.providers.google.baseUrl #53756 with a direct repro against doctor --fix.
  • Why this regressed now: legacy migration handled the model selection + API key move, but not the required provider defaults for a newly created google provider entry.
  • If unknown, what was ruled out: N/A.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/commands/doctor-legacy-config.migrations.test.ts
  • Scenario the test should lock in: migrating legacy skills.entries.nano-banana-pro config with no pre-existing models.providers.google should produce a schema-valid google provider entry including baseUrl and models.
  • Why this is the smallest reliable guardrail: the bug is introduced entirely inside the legacy migration logic, so the migration test is the narrowest place to prevent recurrence.
  • Existing test that already covers this (if any): the nano-banana migration test existed, but it did not assert the full required google provider shape.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

  • openclaw doctor --fix no longer fails validation when migrating legacy skills.entries.nano-banana-pro config into models.providers.google.

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: N/A

Repro + Verification

Environment

  • OS: macOS 25.3.0 (arm64)
  • Runtime/container: local repo checkout, Node 25.5.0, pnpm 10.32.1
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): legacy skills.entries.nano-banana-pro with apiKey or env.GEMINI_API_KEY, and no pre-existing models.providers.google

Steps

  1. Configure legacy skills.entries.nano-banana-pro with an API key.
  2. Ensure models.providers.google is absent.
  3. Run openclaw doctor --fix.

Expected

  • Legacy config migrates successfully.
  • Resulting models.providers.google is schema-valid.

Actual

  • Before this patch, validation failed with models.providers.google.baseUrl: Invalid input: expected string, received undefined.
  • After this patch, the migration test passes and asserts the required google provider shape.

Evidence

Attach at least one:

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

Human Verification (required)

  • Verified scenarios:
    • ran pnpm exec vitest run src/commands/doctor-legacy-config.migrations.test.ts
    • verified migrated config now includes models.providers.google.baseUrl and models.providers.google.models
    • commit-time local checks passed during commit creation
  • Edge cases checked:
    • preserves explicit existing native google provider config
    • prefers legacy env.GEMINI_API_KEY over legacy skill apiKey during migration
  • What you did not verify:
    • did not run full pnpm build && pnpm check && pnpm test
    • did not run broader end-to-end doctor flows
    • did not run codex review --base origin/main yet

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

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

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit 01c8787de4
  • Files/config to restore: src/commands/doctor-legacy-config.ts, src/commands/doctor-legacy-config.migrations.test.ts
  • Known bad symptoms reviewers should watch for: unexpected mutation of explicit existing models.providers.google config beyond filling missing fields in the legacy migration path

Risks and Mitigations

  • Risk: migration could accidentally overwrite explicit google provider config.
    • Mitigation: changes only fill missing defaults in the path where the migration introduces the provider config; existing explicit config remains covered by regression tests.

@openclaw-barnacle openclaw-barnacle bot added commands Command implementations size: XS labels Mar 24, 2026
@eulicesl
Copy link
Copy Markdown
Author

@codex review for correctness and scope. Please focus on whether this is the right fix location for the nano-banana migration bug, whether it preserves explicit existing google provider config, and whether the regression coverage is sufficient for this migration path.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@eulicesl eulicesl marked this pull request as ready for review March 24, 2026 19:34
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR fixes a bug in openclaw doctor --fix where migrating a legacy skills.entries.nano-banana-pro config (with no pre-existing models.providers.google) would produce a google provider entry missing the baseUrl and models fields required by ModelProviderSchema, causing validation to fail.

Changes:

  • Introduces a GOOGLE_PROVIDER_BASE_URL constant (https://generativelanguage.googleapis.com) in the migration function.
  • Adds a googleChanged boolean sentinel that gates both the default-filling logic and the provider-write-back, so baseUrl and models defaults are only applied when the migration is actively creating the google provider entry — never when an explicit provider config already exists.
  • Extends two existing migration test cases to assert the full required google provider shape (baseUrl and models) after migration, locking in the fix.

Confidence Score: 5/5

  • This PR is safe to merge — it's a narrow, well-tested migration bug fix with no broader side-effects.
  • The fix is minimal and scoped entirely to the nano-banana migration path. The googleChanged flag ensures existing google provider configs are untouched. Tests cover the introduced path (new provider from legacy key), the env-key preference path, and the pre-existing provider preservation path. No security, data-loss, or schema-breakage risk is introduced.
  • No files require special attention.

Reviews (1): Last reviewed commit: "fix(doctor): preserve valid google provi..." | Re-trigger Greptile

@eulicesl eulicesl force-pushed the upstream/fix-doctor-google-provider-defaults branch 3 times, most recently from 4c77d3b to 107736e Compare March 26, 2026 11:16
@eulicesl eulicesl force-pushed the upstream/fix-doctor-google-provider-defaults branch from 5425754 to db02532 Compare March 26, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doctor --fix crashes with Config validation failed on models.providers.google.baseUrl

1 participant