chenhg5/cc-connect · error
download failed with status %d: %s
Error message
download failed with status %d: %s
What it means
downloadSlackFile: non-200 response — often a redirect to a login page when the Bearer authorization header was missing or rejected; the first 1KB of the body is embedded so HTML login pages are visible in the error.
Source
Thrown at platform/slack/slack.go:577
var _ core.FileSender = (*Platform)(nil)
func (p *Platform) downloadSlackFile(url string) ([]byte, error) {
if url == "" {
return nil, fmt.Errorf("empty URL")
}
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("Authorization", "Bearer "+p.botToken)
resp, err := core.HTTPClient.Do(req)
if err != nil {
return nil, fmt.Errorf("%s", core.RedactToken(err.Error(), p.botToken))
}
defer resp.Body.Close()
// Check if we got an unexpected status code (e.g., redirect to login page)
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(io.LimitReader(resp.Body, 1024))
return nil, fmt.Errorf("download failed with status %d: %s", resp.StatusCode, string(body))
}
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read response body: %w", err)
}
// Basic sanity check: detect if we received HTML instead of binary data
if len(data) > 0 && (bytes.HasPrefix(data, []byte("<!DOCTYPE")) || bytes.HasPrefix(data, []byte("<html"))) {
return nil, fmt.Errorf("received HTML response (likely missing auth); first 100 bytes: %s", string(data[:min(100, len(data))]))
}
return data, nil
}
func (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error) {
// slack:{channel}:{user} | slack:{channel}:t:{threadTS} | slack:{channel}
parts := strings.SplitN(sessionKey, ":", 3)View on GitHub (pinned to 4000b2338a)
Solutions
- Ensure the 'Bearer '+botToken header is sent
- Check the token has files:read scope
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at platform/slack/slack.go:577 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/436868723fc10f3f.
Report an issue: GitHub.