{"record":{"id":"d3503be19841dbfb","repo":"docmirror/dev-sidecar","slug":"error-d3503b","errorCode":null,"errorMessage":"下载远程配置成功，但内容为空:","messagePattern":"下载远程配置成功，但内容为空:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/src/config-api.js","lineNumber":71,"sourceCode":"    return new Promise((resolve, reject) => {\n      log.info('开始下载远程配置:', remoteConfigUrl)\n\n      const headers = {\n        'Cache-Control': 'no-cache', // 禁止使用缓存\n        'Pragma': 'no-cache', // 禁止使用缓存\n      }\n      if (remoteConfigUrl.startsWith('https://raw.githubusercontent.com/')) {\n        headers['Server-Name'] = 'baidu.com'\n      }\n      request(remoteConfigUrl, { headers }, (error, response, body) => {\n        if (error) {\n          log.error(`下载远程配置失败: ${remoteConfigUrl}, error:`, error, ', response:', response, ', body:', body)\n          reject(error)\n          return\n        }\n        if (response && response.statusCode === 200) {\n          if (body == null || body.length < 2) {\n            log.warn('下载远程配置成功，但内容为空:', remoteConfigUrl)\n            resolve()\n            return\n          } else {\n            log.info('下载远程配置成功:', remoteConfigUrl)\n          }\n\n          // 尝试解析远程配置，如果解析失败，则不保存它\n          let remoteConfig\n          try {\n            remoteConfig = jsonApi.parse(body)\n          } catch {\n            log.error(`远程配置内容格式不正确, url: ${remoteConfigUrl}, body: ${body}`)\n            remoteConfig = null\n          }\n\n          if (remoteConfig != null) {\n            const remoteSavePath = configLoader.getRemoteConfigPath(suffix)\n            try {","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/core/src/config-api.js#L53-L89","documentation":"doDownloadRemoteConfig resolves successfully-but-emptily (resolve() with no value) when the remote config URL returns HTTP 200 but the body is null or shorter than 2 characters. A warning is logged with the URL. The empty body is treated as 'no override' rather than an error, so defaults/other config layers are used.","triggerScenarios":"Downloading a remote shared/personal config (config.remoteConfigUrl) where the server responds 200 with an empty body: a zero-byte file on the static host, a 200-wrapped error page stripped of content, or a CDN returning an empty successful response.","commonSituations":"User published an empty config file to gitee/github raw; wrong URL pointing to an empty placeholder; private repo/CDN returning empty 200 without auth; file truncated on upload.","solutions":["Open the remoteConfigUrl in a browser and confirm it actually serves non-empty JSON5 content","Fix the source file (commit/push the intended config) if it was uploaded empty","Verify the URL points to the raw file, not an HTML wrapper page","If the empty config is intentional, ignore the warning — defaults and local overrides still apply"],"exampleFix":"// before (empty file on host)\n// after — ensure remote config file contains at least valid content, e.g.\n{ }\n","handlingStrategy":"fallback","validationCode":"async function remoteConfigHasContent(url) {\n  const res = await fetch(url)\n  const text = await res.text()\n  return res.status === 200 && text.trim().length >= 2\n}\n// verify before configuring remoteConfigUrl, or warn the user","typeGuard":"function isEmptyRemoteBody(body) {\n  return body == null || body.length < 2\n}","tryCatchPattern":"const cfg = await downloadRemoteConfig(url) // resolves undefined on empty\nif (cfg == null) {\n  log.warn('Remote config empty; falling back to defaults + local overrides')\n}","preventionTips":["Verify the remote config URL serves real content before wiring it into config","Point at raw file URLs (raw.githubusercontent / raw gitee), not HTML pages","Keep remote config files non-empty and valid JSON5 even when 'empty' means no overrides — use '{}'","Remember empty remote config is non-fatal: defaults and ~/.dev-sidecar/config.json still apply"],"tags":["config","remote-config","network"],"backgroundTag":"empty-remote-config","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}