{"record":{"id":"78b46510fc453415","repo":"xpzouying/xiaohongshu-mcp","slug":"s-s","errorCode":null,"errorMessage":"当前平台 %s/%s 无预编译浏览器，暂不支持","messagePattern":"当前平台 (.+?)/(.+?) 无预编译浏览器，暂不支持","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"browser/browser_download.go","lineNumber":74,"sourceCode":"\t\treturn \"windows-x64.zip\", \"chrome.exe\", true\n\t}\n\treturn \"\", \"\", false\n}\n\nfunc browserCacheDir() (string, error) {\n\tbase, err := os.UserCacheDir()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn filepath.Join(base, \"xiaohongshu-mcp\", \"browser\", browserVersion), nil\n}\n\n// EnsureBrowser 确保本地存在内置浏览器二进制，返回其路径。\n// 已缓存则直接返回；否则下载 → 校验 SHA256 → 解压。当前平台无预编译二进制时返回 error。\nfunc EnsureBrowser() (string, error) {\n\tasset, binName, ok := platformAsset()\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"当前平台 %s/%s 无预编译浏览器，暂不支持\", runtime.GOOS, runtime.GOARCH)\n\t}\n\n\tcacheDir, err := browserCacheDir()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// 已缓存：遍历查找二进制\n\tif bin := findBinary(cacheDir, binName); bin != \"\" {\n\t\treturn bin, nil\n\t}\n\n\tif err := os.MkdirAll(cacheDir, 0o755); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// 下载（重试 3 次）\n\tlogrus.Infof(\"首次运行：下载内置浏览器 %s（%s，约 140-190MB，仅一次）...\", browserVersion, asset)","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/browser/browser_download.go#L56-L92","documentation":"EnsureBrowser 的平台支持守卫：platformAsset() 对当前 runtime.GOOS/runtime.GOARCH 组合没有对应的预编译浏览器资产，即该操作系统/架构不在内置浏览器分发列表中，属环境不支持而非下载故障。","triggerScenarios":"在不支持的平台调用 EnsureBrowser（直接或经 NewBrowser）：linux/arm64（如 ARM 云主机、树莓派）、darwin/amd64（Intel Mac）、freebsd 等。","commonSituations":"在 ARM Linux 服务器/容器中部署；仍在 Intel Mac 上运行；CI 使用非 amd64 runner。","solutions":["在支持的平台上运行：darwin/arm64、linux/amd64 或 windows/amd64","自建对应平台的 Chromium 并通过系统浏览器路径启动（绕过内置浏览器下载）","若必须支持该平台，向 platformAsset 增加对应 asset 并提供下载/SHA256","在文档/启动检查中提前提示平台要求"],"exampleFix":"// before\nbin, err := browser.EnsureBrowser() // linux/arm64 上报错\n// after\nif !isSupportedPlatform() {\n\treturn fmt.Errorf(\"unsupported platform %s/%s\", runtime.GOOS, runtime.GOARCH)\n}\nbin, err := browser.EnsureBrowser()","handlingStrategy":"fallback","validationCode":"func platformSupported() bool {\n\tswitch runtime.GOOS {\n\tcase \"darwin\":\n\t\treturn runtime.GOARCH == \"arm64\"\n\tcase \"linux\", \"windows\":\n\t\treturn runtime.GOARCH == \"amd64\"\n\t}\n\treturn false\n}\n// 部署/启动前: if !platformSupported() { ... }","typeGuard":"func isSupportedPlatform() bool {\n\treturn (runtime.GOOS == \"linux\" && runtime.GOARCH == \"amd64\") ||\n\t\t(runtime.GOOS == \"windows\" && runtime.GOARCH == \"amd64\") ||\n\t\t(runtime.GOOS == \"darwin\" && runtime.GOARCH == \"arm64\")\n}","tryCatchPattern":null,"preventionTips":["部署前用 runtime.GOOS/GOARCH 检查平台支持","CI runner 固定为 linux/amd64","在 README 中标注支持平台清单","不支持时回退到系统安装的浏览器路径"],"tags":["platform","unsupported-os-arch","browser-download"],"backgroundTag":"unsupported-platform","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}