xpzouying/xiaohongshu-mcp · error

获取 SHA256SUMS: HTTP %d

Error message

获取 SHA256SUMS: HTTP %d

What it means

fetchExpectedSHA fetches the SHA256SUMS checksum file published alongside browser assets and parses lines of the form '<hash>␠␠<filename>'. This error is thrown when the HTTP response status is not 200 OK, meaning the checksum manifest could not be retrieved from the download server.

Source

Thrown at browser/browser_download.go:157

	h := sha256.New()
	if _, err := io.Copy(h, f); err != nil {
		return err
	}
	got := hex.EncodeToString(h.Sum(nil))
	if !strings.EqualFold(got, want) {
		return fmt.Errorf("%s SHA256 不匹配:期望 %s,实际 %s", asset, want, got)
	}
	return nil
}

func fetchExpectedSHA(asset string) (string, error) {
	resp, err := (&http.Client{Timeout: 30 * time.Second}).Get(browserURL("SHA256SUMS"))
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return "", fmt.Errorf("获取 SHA256SUMS: HTTP %d", resp.StatusCode)
	}
	sc := bufio.NewScanner(resp.Body)
	for sc.Scan() {
		// 格式:<hash>␠␠<filename>
		fields := strings.Fields(sc.Text())
		if len(fields) == 2 && fields[1] == asset {
			return fields[0], nil
		}
	}
	return "", fmt.Errorf("SHA256SUMS 中未找到 %s", asset)
}

func findBinary(dir, binName string) string {
	var found string
	_ = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
		if err != nil || info.IsDir() {
			return nil
		}

View on GitHub (pinned to 332d196854)

Solutions

  1. Check that the resolved browserURL("SHA256SUMS") actually exists by fetching it manually with curl and inspecting the status code
  2. Retry later if the status is 5xx — it is usually a transient CDN/server issue
  3. If behind a proxy, verify the proxy allows GET to that host/path and does not inject an auth redirect (401/403)
  4. Clear any cached/pinned browser version and let EnsureBrowser resolve a currently published version
  5. Update the library/download URL base if the upstream project moved its release assets

Example fix

// before
resp, err := (&http.Client{Timeout: 30 * time.Second}).Get(browserURL("SHA256SUMS"))
// after — inspect status before treating it as fatal, allow a retry
for i := 0; i < 3; i++ {
	resp, err := (&http.Client{Timeout: 30 * time.Second}).Get(browserURL("SHA256SUMS"))
	if err == nil && resp.StatusCode == http.StatusOK {
		break
	}
	time.Sleep(time.Second * time.Duration(i+1))
}
Defensive patterns

Strategy: retry

Validate before calling

url := browserURL("SHA256SUMS")
resp, err := http.Head(url)
if err != nil || resp.StatusCode != http.StatusOK {
	// 上游清单不可用,跳过校验或延后重试
}

Try / catch

expected, err := fetchExpectedSHA(asset)
if err != nil {
	if strings.Contains(err.Error(), "HTTP ") {
		// 网络/服务端问题:等待后重试
		time.Sleep(5 * time.Second)
		expected, err = fetchExpectedSHA(asset)
	}
	if err != nil { return fmt.Errorf("校验失败: %w", err) }
}

Prevention

When it happens

Trigger: EnsureBrowser -> verifySHA256 -> fetchExpectedSHA performs http.Get(browserURL("SHA256SUMS")) and the server responds with a status other than 200 (e.g. 404, 403, 5xx) while the request itself succeeds at the transport level.

Common situations: The upstream browser download CDN changed its layout so SHA256SUMS no longer exists at the expected path; a corporate proxy or mirror returns 403; transient CDN 5xx during an outage; the configured browser version/URL points to an untagged or removed release.

Related errors


AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05). Data as JSON: /api/errors/5680c42c54f56a09. Report an issue: GitHub.