{"record":{"id":"60baf432f1155e3b","repo":"docmirror/dev-sidecar","slug":"domestic-domain-allowlist-txt","errorCode":null,"errorMessage":"下载远程 domestic-domain-allowlist.txt 文件成功，但内容为空或内容太短，判断为无效的 domestic-domain-allowlist.txt 文件:","messagePattern":"下载远程 domestic-domain-allowlist\\.txt 文件成功，但内容为空或内容太短，判断为无效的 domestic-domain-allowlist\\.txt 文件:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/src/shell/scripts/set-system-proxy/index.js","lineNumber":40,"sourceCode":"}\n\nfunction getDomesticDomainAllowListTmpFilePath () {\n  return path.join(config.get().server.setting.userBasePath, '/domestic-domain-allowlist.txt')\n}\n\nasync function downloadDomesticDomainAllowListAsync () {\n  loadConfig()\n\n  const remoteFileUrl = config.get().proxy.remoteDomesticDomainAllowListFileUrl\n  log.info('开始下载远程 domestic-domain-allowlist.txt 文件:', remoteFileUrl)\n  request(remoteFileUrl, (error, response, body) => {\n    if (error) {\n      log.error(`下载远程 domestic-domain-allowlist.txt 文件失败: ${remoteFileUrl}, error:`, error, ', response:', response, ', body:', body)\n      return\n    }\n    if (response && response.statusCode === 200) {\n      if (body == null || body.length < 100) {\n        log.warn('下载远程 domestic-domain-allowlist.txt 文件成功，但内容为空或内容太短，判断为无效的 domestic-domain-allowlist.txt 文件:', remoteFileUrl, ', body:', body)\n        return\n      } else {\n        log.info('下载远程 domestic-domain-allowlist.txt 文件成功:', remoteFileUrl)\n      }\n\n      let fileTxt = body\n      try {\n        if (!fileTxt.includes('*.')) {\n          fileTxt = Buffer.from(fileTxt, 'base64').toString('utf8')\n          // log.debug('解析 base64 后的 domestic-domain-allowlist:', fileTxt)\n        }\n      } catch {\n        if (!fileTxt.includes('*.')) {\n          log.error(`远程 domestic-domain-allowlist.txt 文件内容即不是base64格式，也不是要求的格式，url: ${remoteFileUrl}，body: ${body}`)\n          return\n        }\n      }\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/core/src/shell/scripts/set-system-proxy/index.js#L22-L58","documentation":"A warning log in downloadDomesticDomainAllowListAsync (packages/core/src/shell/scripts/set-system-proxy/index.js:39-41). The remote domestic-domain allowlist file was downloaded with HTTP 200, but the body is null or shorter than 100 characters, so it is judged invalid and discarded — the local allowlist file is not updated. The system-proxy PAC/allowlist then keeps using the previously cached file.","triggerScenarios":"The URL in config `proxy.remoteDomesticDomainAllowListFileUrl` returns HTTP 200 with an empty/short body — e.g. a mirror or CDN returning an empty stub, a redirect page captured as 200, a rate-limited/captcha response, or a custom self-hosted allowlist file that is truncated.","commonSituations":"Users pointing remoteDomesticDomainAllowListFileUrl at a custom gist/mirror whose content is empty or not the expected domain-list format; a proxy/firewall intercepting the request and returning a 200 block page; the upstream repo file temporarily unavailable via the mirror.","solutions":["Log/inspect the returned body (it is printed in the warning) to see what the server actually sent (HTML block page? empty string?).","Check/correct `proxy.remoteDomesticDomainAllowListFileUrl` in `~/.dev-sidecar/config.json` to point at the official raw allowlist file URL.","Verify with curl that the URL returns the real file (non-empty, >100 chars, containing `*.` domain entries or valid base64).","Restore the previous local file `~/.dev-sidecar/domestic-domain-allowlist.txt` (the code leaves it untouched on this warning) or write a valid one manually.","Retry later if it was a transient mirror/CDN glitch; the download runs again on the next system-proxy refresh."],"exampleFix":"// before (config.json)\n\"proxy\": { \"remoteDomesticDomainAllowListFileUrl\": \"https://my-mirror.example/allowlist.txt\" }\n// after\n\"proxy\": { \"remoteDomesticDomainAllowListFileUrl\": \"https://raw.githubusercontent.com/docmirror/dev-sidecar/master/packages/core/src/shell/scripts/set-system-proxy/domestic-domain-allowlist.txt\" }","handlingStrategy":"validation","validationCode":"const https = require('node:https')\nfunction isValidAllowListUrl (url) {\n  return new Promise((resolve) => {\n    https.get(url, (res) => {\n      let n = 0\n      res.on('data', (c) => { n += c.length })\n      res.on('end', () => resolve(res.statusCode === 200 && n >= 100))\n    }).on('error', () => resolve(false))\n  })\n}\n// usage: if (!(await isValidAllowListUrl(cfg.proxy.remoteDomesticDomainAllowListFileUrl))) fixConfigFirst()","typeGuard":"function isValidAllowListBody (body) {\n  return typeof body === 'string' && body.length >= 100\n}","tryCatchPattern":null,"preventionTips":["Verify remoteDomesticDomainAllowListFileUrl with curl before configuring it: must return 200 with >100 chars containing `*.` entries or base64.","Point the URL at raw file endpoints, not HTML pages or redirects that collapse to a 200 stub.","Keep a good local fallback at ~/.dev-sidecar/domestic-domain-allowlist.txt; the code preserves it when this warning fires.","Periodically re-check the mirror/CDN serving the file for empty or rate-limited responses."],"tags":["network","http","config","allowlist","empty-response"],"backgroundTag":"empty-http-response-body","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}