Tencent/WeKnora · error
download file: %w
Error message
download file: %w
What it means
DownloadFile retries HTTP requests up to maxRetries times. If every attempt fails (network error or exhausted retries on non-200 status), the last error is wrapped as "download file: %w" and returned. It is a generic transport-level failure for attachment downloads from Notion's file hosts.
Source
Thrown at internal/datasource/connector/notion/client.go:427
return nil, sErr
}
continue
}
break
}
data, err := io.ReadAll(io.LimitReader(resp.Body, maxDownloadSize+1))
resp.Body.Close()
if err != nil {
return nil, err
}
if int64(len(data)) > maxDownloadSize {
return nil, fmt.Errorf("file exceeds maximum download size (%d MB)", maxDownloadSize/(1024*1024))
}
return data, nil
}
return nil, fmt.Errorf("download file: %w", lastErr)
}
// --- Shared pagination helper ---
// paginatePages fetches all pages from a paginated Notion API endpoint.
func (c *notionClient) paginatePages(ctx context.Context, method, path string) ([]notionPage, error) {
var allPages []notionPage
var startCursor string
for {
body := map[string]interface{}{
"page_size": 100,
}
if startCursor != "" {
body["start_cursor"] = startCursor
}
var respBody []byteView on GitHub (pinned to 988cbb0330)
Solutions
- Inspect the wrapped lastErr (via errors.Unwrap or %v) to see the actual cause
- Re-run the fetch; signed attachment URLs are transient, a fresh page fetch yields new URLs
- Check outbound network/proxy access from the connector host
- Re-index the page so Notion issues a fresh download URL
Example fix
data, err := client.DownloadFile(ctx, fileURL)
if err != nil {
return fmt.Errorf("skipping attachment: %w", err) // don't fail whole page
} Defensive patterns
Strategy: retry
Validate before calling
u, err := url.Parse(fileURL); if err != nil || u.Scheme != "https" { return err } Try / catch
data, err := client.DownloadFile(ctx, url)
if err != nil {
var urlErr *url.Error
if errors.As(err, &urlErr) && isTransient(urlErr) {
// schedule re-fetch later; signed URLs expire
}
return fmt.Errorf("attachment download skipped: %w", err)
} Prevention
- Treat attachment URLs as ephemeral — re-fetch pages to get fresh URLs
- Add backoff retry at the caller level for transient network errors
- Monitor outbound connectivity from the connector host
When it happens
Trigger: All retry attempts in DownloadFile fail: transient network errors, DNS failures, or repeated non-200 responses (403/404/500) from the attachment URL after retries are exhausted.
Common situations: Expired or revoked Notion file URLs (signed S3 URLs expire), outage of Notion's file CDN, connector host has no outbound internet access, attachment deleted between listing and download.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- create download request: %w
- download failed with status %d
- download: %w
- download zip: %w
- download jsonl: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/60f4ef02663a635e.
Report an issue: GitHub.