Skip to content

Doctor: handle SecretRef apiKey in memory-search health check#35755

Closed
echoVic wants to merge 1 commit intoopenclaw:mainfrom
echoVic:codex/fix-doctor-memory-search-secretref-35444
Closed

Doctor: handle SecretRef apiKey in memory-search health check#35755
echoVic wants to merge 1 commit intoopenclaw:mainfrom
echoVic:codex/fix-doctor-memory-search-secretref-35444

Conversation

@echoVic
Copy link
Copy Markdown
Contributor

@echoVic echoVic commented Mar 5, 2026

Summary

  • avoid calling string methods on agents.defaults.memorySearch.remote.apiKey in doctor health checks
  • treat configured SecretRef values as valid configured API key input
  • add regression coverage to ensure openclaw doctor no longer crashes on SecretRef-shaped API keys

Testing

  • pnpm test src/commands/doctor-memory-search.test.ts

Closes #35444

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 5, 2026

Greptile Summary

This PR fixes a crash in openclaw doctor that occurred when agents.defaults.memorySearch.remote.apiKey was configured as a SecretRef object instead of a plain string. The original code called .trim() directly on the apiKey value, which throws on non-string types.

Changes:

  • doctor-memory-search.ts: Replaces Boolean(resolved?.remote?.apiKey?.trim()) with hasConfiguredSecretInput(resolved?.remote?.apiKey), an existing utility that safely handles both plain strings and SecretRef objects.
  • doctor-memory-search.test.ts: Adds a regression test verifying that a SecretRef-shaped apiKey (e.g. { source: "env", provider: "default", id: "OPENAI_API_KEY" }) neither triggers a warning note nor unnecessarily invokes resolveApiKeyForProvider.

Confidence Score: 5/5

  • This PR is safe to merge — it fixes a targeted crash with minimal scope and includes a regression test.
  • The change is a single-line fix replacing a type-unsafe string method call with a well-established utility that already handles both string and SecretRef union types. No new logic is introduced. The fix is symmetric across both the explicit provider path and the auto provider loop (both consume the same hasRemoteApiKey variable). The regression test uses the real hasConfiguredSecretInput implementation, giving genuine coverage. No side effects or behavioral changes beyond the crash fix.
  • No files require special attention.

Last reviewed commit: e32d37e

@joshavant
Copy link
Copy Markdown
Contributor

Thanks for the contribution here, and for helping narrow down the SecretRef doctor crash.

We merged #36835, which supersedes this PR and fixes the broader doctor/memory SecretRef surface in one place, including the related runtime embedding paths.

I’m closing this as superseded by #36835, but I appreciate the fix and the investigation that went into it.

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.

openclaw doctor crashes with TypeError on SecretRef/vault-resolved apiKey values

2 participants