docmirror/dev-sidecar · warning
newConfig 为空,不做任何操作
Error message
newConfig 为空,不做任何操作
What it means
Warning logged by the set(newConfig) API in config-api.js when it is called with null or undefined. Instead of crashing, the function short-circuits and returns the current configTarget unchanged — no config is loaded or applied. It is a defensive no-op guard.
Source
Thrown at packages/core/src/config-api.js:194
}
},
doMerge: mergeApi.doMerge,
doDiff: mergeApi.doDiff,
/**
* 读取 config.json 后,合并配置
*/
reload () {
const userConfig = configLoader.getUserConfig()
return configApi.set(userConfig) || {}
},
update (partConfig) {
const newConfig = lodash.merge(configApi.get(), partConfig)
configApi.save(newConfig)
},
get,
set (newConfig) {
if (newConfig == null) {
log.warn('newConfig 为空,不做任何操作')
return configTarget
}
return configApi.load(newConfig)
},
load (newConfig) {
const config = configLoader.getConfigFromFiles(newConfig, defConfig)
configTarget = config
return config
},
cloneDefault () {
return lodash.cloneDeep(defConfig)
},
addDefault (key, defValue) {
lodash.set(defConfig, key, defValue)
},
// 移除用户配置,用于恢复出厂设置功能
async removeUserConfig () {
const configPath = configLoader.getUserConfigPath()View on GitHub (pinned to 7710cd56cc)
Solutions
- Ensure the caller builds a real config object before calling set() (e.g. pass {} instead of null to load defaults).
- If reading config from disk, fall back to {} when the file is missing/empty before calling set().
- Check upstream logic that computes the diff/override passed to set() and fix the null source.
- If null is intentional as a no-op, ignore the warning — behavior is safe and current config is returned.
Example fix
// before
const part = readUserOverride(); // may be null
DevSidecar.config.set(part)
// after
const part = readUserOverride() || {}
DevSidecar.config.set(part) Defensive patterns
Strategy: type-guard
Validate before calling
if (newConfig == null) {
console.warn('config is null, skipping set()')
return
}
DevSidecar.config.set(newConfig) Type guard
function isConfigObject(v) {
return v != null && typeof v === 'object' && !Array.isArray(v)
} Prevention
- Default optional config reads to {} before calling set().
- Validate persisted config files (config.json) are non-empty before loading them.
- Never pass through possibly-null computed diffs directly to set().
- Treat this warning as a no-op signal: current config is returned unchanged.
When it happens
Trigger: Calling DevSidecar.config.set(null) or set(undefined) directly, or indirectly when configApi.save(diffConfig) produced a null/undefined diff (e.g. new config equals defaults and merge logic yields null) that is then passed back through set.
Common situations: GUI/CLI code that reads a persisted user override from ~/.dev-sidecar/config.json which is missing or empty and passes the result straight to set(); plugin code passing an optional config object that was never initialized; refactored callers that no longer build the partConfig before merging.
Related errors
- Unknown type DNS: ${server}, provider: ${provider}
- 下载远程配置成功,但内容为空:
- 远程配置对象为空:
- 下载远程 domestic-domain-allowlist.txt 文件成功,但内容为空或内容太短,判断为无效的 do
- 域名 ${rOptions.hostname} 在dns中未配置,但使用了 sni: ${rOptions.server
AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31).
Data as JSON: /api/errors/1654579be5d1d31e.
Report an issue: GitHub.