docmirror/dev-sidecar · warning

远程配置对象为空:

Error message

远程配置对象为空:

What it means

This is a warning logged (not a thrown Error) inside doDownloadRemoteConfig of config-api.js. It means the remote config URL returned HTTP 200 with a body, but after JSON5 parsing the result was null/empty — i.e. the downloaded content is not a usable config object. The library intentionally does not overwrite or reject: it skips saving the remote config file and resolves so startup continues with whatever config exists locally.

Source

Thrown at packages/core/src/config-api.js:98

          try {
            remoteConfig = jsonApi.parse(body)
          } catch {
            log.error(`远程配置内容格式不正确, url: ${remoteConfigUrl}, body: ${body}`)
            remoteConfig = null
          }

          if (remoteConfig != null) {
            const remoteSavePath = configLoader.getRemoteConfigPath(suffix)
            try {
              fs.writeFileSync(remoteSavePath, body)
              log.info('保存远程配置文件成功:', remoteSavePath)
            } catch (e) {
              log.error('保存远程配置文件失败:', remoteSavePath, ', error:', e)
              reject(new Error(`保存远程配置文件失败: ${e.message}`))
              return
            }
          } else {
            log.warn('远程配置对象为空:', remoteConfigUrl)
          }

          resolve()
        } else {
          log.error(`下载远程配置失败: ${remoteConfigUrl}, response:`, response, ', body:', body)

          let message
          if (response) {
            message = `下载远程配置失败: ${remoteConfigUrl}, message: ${response.statusMessage}, code: ${response.statusCode}`
          } else {
            message = `下载远程配置失败: response: ${response}`
          }
          reject(new Error(message))
        }
      })
    })
  },
  deleteRemoteConfigFile (suffix = '') {

View on GitHub (pinned to 7710cd56cc)

Solutions

  1. Open the remote config URL in a browser or curl it and verify the body is valid JSON/JSON5 (an object, not HTML or empty text).
  2. Fix the app.remoteConfig.url in your config to point at the raw JSON/JSON5 file (for GitHub use raw.githubusercontent.com URLs).
  3. If you intentionally disabled the remote config, restore its content upstream or set app.remoteConfig.enabled=false.
  4. Check for intermediaries (proxy/portal) returning 200 HTML stubs; bypass them or correct DNS/SNI settings.

Example fix

// before
app: { remoteConfig: { enabled: true, url: 'https://github.com/user/config/blob/main/shared.json5' } }
// after
app: { remoteConfig: { enabled: true, url: 'https://raw.githubusercontent.com/user/config/main/shared.json5' } }
Defensive patterns

Strategy: validation

Validate before calling

const res = await fetch(url)
const text = await res.text()
let cfg = null
try { cfg = JSON.parse(text) } catch {}
if (res.ok && cfg && typeof cfg === 'object' && Object.keys(cfg).length > 0) {
  // safe to use as remote config
} else {
  console.warn('remote config empty/invalid, keeping local config:', url)
}

Type guard

function isValidConfigObject(v) {
  return v != null && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length > 0
}

Prevention

When it happens

Trigger: doDownloadRemoteConfig fetched app.remoteConfig.url (or personalUrl) and got a 200 response, but jsonApi.parse(body) yielded null — e.g. body was whitespace/HTML stripped to nothing, a parse fallback produced null, or the server returned an empty-ish document that passed the body.length<2 check but parsed to null.

Common situations: The remote config URL points at an HTML page instead of raw JSON/JSON5 (e.g. a GitHub HTML view rather than raw.githubusercontent.com); the file on the remote repo was emptied or renamed; a captive portal or CDN returns 200 with a stub page; a shared-config gist was deleted and the host serves an empty 200 page.

Related errors


AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31). Data as JSON: /api/errors/bd16a4a3622c705d. Report an issue: GitHub.