fix: #89 stripUiFields清理version info根字段,防止污染openclaw.json导致Gateway启动失败

This commit is contained in:
晴天
2026-03-16 19:24:32 +08:00
parent 55ee177785
commit 6665c4fc5f
2 changed files with 38 additions and 12 deletions

View File

@@ -560,17 +560,29 @@ function getUid() {
}
function stripUiFields(config) {
// 清理根层级 ClawPanel 内部字段version info 等),避免污染 openclaw.json
// Issue #89: 这些字段被写入 openclaw.json 后导致 Gateway 无法启动Unknown config keys
const uiRootKeys = [
'current', 'latest', 'recommended', 'update_available',
'latest_update_available', 'is_recommended', 'ahead_of_recommended',
'panel_version', 'source',
]
for (const key of uiRootKeys) {
delete config[key]
}
// 清理模型测试相关的临时字段
const providers = config?.models?.providers
if (!providers) return config
for (const p of Object.values(providers)) {
if (!Array.isArray(p.models)) continue
for (const m of p.models) {
if (typeof m !== 'object') continue
delete m.lastTestAt
delete m.latency
delete m.testStatus
delete m.testError
if (!m.name && m.id) m.name = m.id
if (providers) {
for (const p of Object.values(providers)) {
if (!Array.isArray(p.models)) continue
for (const m of p.models) {
if (typeof m !== 'object') continue
delete m.lastTestAt
delete m.latency
delete m.testStatus
delete m.testError
if (!m.name && m.id) m.name = m.id
}
}
}
return config