fix(xai): make x_search auth plugin-owned#59691
Conversation
Greptile SummaryThis PR removes The refactor is logically sound. The two P2 notes below are minor: dead computed variables in Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/xai/x-search.ts
Line: 98-112
Comment:
**Dead variables left after refactor**
`sourceXSearchConfig` and `runtimeXSearchConfig` are assigned but never read — they were presumably used when the function still fell back to the legacy x_search config. After removing those fallbacks, both variables are now unreachable dead code and can be deleted.
```suggestion
function resolveXSearchApiKey(params: {
sourceConfig?: OpenClawConfig;
runtimeConfig?: OpenClawConfig;
}): string | undefined {
return (
resolveFallbackXaiApiKey(params.runtimeConfig) ??
resolveFallbackXaiApiKey(params.sourceConfig) ??
readProviderEnvValue(["XAI_API_KEY"])
);
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/secrets/runtime.ts
Line: 171-174
Comment:
**Fallback no longer applies x_search migration on validation failure**
Previously, when `migrateLegacyConfig` returned `config: null` (migration applied but validation failed), the fallback still ran `migrateLegacyXSearchConfig` on `params.config`, so the legacy `tools.web.x_search.apiKey` was surfaced under the plugin path at runtime. Now `params.config` is used as-is, so x_search auth is not migrated in that path.
This only affects users who simultaneously have a legacy `tools.web.x_search.apiKey` **and** a separate schema violation that fails post-migration validation — an already-broken config. Worth documenting as a known edge case if there are any known consumers of this snapshot function with partially-invalid configs.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Merge branch 'main' into chore/x-search-..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77cf7bde2a
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e6da7c617
ℹ️ 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".
* fix(xai): make x_search auth plugin-owned * fix(xai): restore x_search runtime migration fallback * fix(xai): narrow legacy x_search auth migration * fix(secrets): drop legacy x_search target registry entry * fix(xai): no-op knob-only x_search migration fallback
* fix(xai): make x_search auth plugin-owned * fix(xai): restore x_search runtime migration fallback * fix(xai): narrow legacy x_search auth migration * fix(secrets): drop legacy x_search target registry entry * fix(xai): no-op knob-only x_search migration fallback
* fix(xai): make x_search auth plugin-owned * fix(xai): restore x_search runtime migration fallback * fix(xai): narrow legacy x_search auth migration * fix(secrets): drop legacy x_search target registry entry * fix(xai): no-op knob-only x_search migration fallback
* fix(xai): make x_search auth plugin-owned * fix(xai): restore x_search runtime migration fallback * fix(xai): narrow legacy x_search auth migration * fix(secrets): drop legacy x_search target registry entry * fix(xai): no-op knob-only x_search migration fallback
* fix(xai): make x_search auth plugin-owned * fix(xai): restore x_search runtime migration fallback * fix(xai): narrow legacy x_search auth migration * fix(secrets): drop legacy x_search target registry entry * fix(xai): no-op knob-only x_search migration fallback
* fix(xai): make x_search auth plugin-owned * fix(xai): restore x_search runtime migration fallback * fix(xai): narrow legacy x_search auth migration * fix(secrets): drop legacy x_search target registry entry * fix(xai): no-op knob-only x_search migration fallback
Summary
x_searchstill exposed a separate core auth surface attools.web.x_search.apiKeyeven though xAI auth is already plugin-owned viaplugins.entries.xai.config.webSearch.apiKey/XAI_API_KEY.#59674.tools.web.x_search.apiKeyfrom the canonical schema and generated SecretRef/config surfaces, moved x-search legacy migration into the shared legacy-config load path, and kept runtime behavior compatible by resolving migrated plugin-owned auth.tools.web.x_search.*still exists for behavior knobs (enabled,model,inlineCitations,maxTurns,timeoutSeconds,cacheTtlMinutes); this PR does not change xAI request behavior beyond auth resolution.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
#59674moved x_search settings behind the xAI plugin boundary but left the legacy auth slot (tools.web.x_search.apiKey) in the canonical schema and SecretRef surfaces.git blame, prior PR, issue, or refactor if known):#59674established plugin-owned xSearch config but stopped short of removing the legacy auth field from core surfaces.Regression Test Plan (if applicable)
tools.web.x_search.apiKeyis migrated into plugin-owned xAI auth on normal config load, while canonical config/SecretRef surfaces no longer expose the legacy key.src/config/legacy-x-search.test.tsandsrc/commands/doctor-legacy-config.migrations.test.tscovered doctor migration only.User-visible / Behavior Changes
tools.web.x_search.apiKeyis no longer a canonical supported config/SecretRef surface.plugins.entries.xai.config.webSearch.apiKeyduring normal config load andopenclaw doctor --fix.x_searchcontinues to use plugin-owned/shared xAI auth orXAI_API_KEY.Diagram (if applicable)
Security Impact (required)
Yes/No): NoYes/No): YesYes/No): NoYes/No): NoYes/No): NoYes, explain risk + mitigation: auth resolution is narrowed, not broadened. The legacy x_search key is removed from canonical SecretRef/config surfaces, while automatic migration preserves backwards compatibility.Repro + Verification
Environment
tools.web.x_search.apiKeyand plugin-ownedplugins.entries.xai.config.webSearch.apiKeySteps
tools.web.x_search.apiKeyand start through normal config-load/runtime paths.plugins.entries.xai.config.webSearch.apiKeyandx_searchstill executes.tools.web.x_search.apiKeyas canonical.Expected
Actual
Evidence
Human Verification (required)
pnpm tsgo,pnpm build.Review Conversations
Compatibility / Migration
Yes/No): YesYes/No): YesYes/No): Notools.web.x_search.apiKeyauto-migrates on load and throughopenclaw doctor --fix; canonical config isplugins.entries.xai.config.webSearch.apiKeyorXAI_API_KEY.Risks and Mitigations