Tencent/WeKnora · warning
file exceeds maximum download size (%d MB)
Error message
file exceeds maximum download size (%d MB)
What it means
DownloadFile in the Notion connector enforces a hard cap (maxDownloadSize) on attachment downloads. It reads at most maxDownloadSize+1 bytes with io.LimitReader; if the extra byte is present the file is over the limit and the download is aborted with this error. This protects memory from oversized Notion-hosted file attachments.
Source
Thrown at internal/datasource/connector/notion/client.go:422
if resp.StatusCode != http.StatusOK {
resp.Body.Close()
lastErr = fmt.Errorf("download failed with status %d", resp.StatusCode)
if resp.StatusCode >= 500 && attempt < maxRetries {
if sErr := sleepWithContext(ctx, time.Duration(1<<attempt)*time.Second); sErr != nil {
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,
}View on GitHub (pinned to 988cbb0330)
Solutions
- Skip or exclude the oversized attachment from indexing instead of downloading it whole
- Stream the file to disk instead of reading it fully into memory if it must be stored
- Raise the connector's maxDownloadSize limit if your deployment has the memory budget
Example fix
// before
data, err := client.DownloadFile(ctx, fileURL)
// after
if isOversizedAttachment(fileSizeBytes) { // check metadata/size first
log.Printf("skipping attachment %s: too large", fileURL)
return nil
}
data, err := client.DownloadFile(ctx, fileURL) Defensive patterns
Strategy: validation
Validate before calling
if fileSizeKnown && int64(fileSizeKnown) > maxDownloadSize { skipAttachment(fileURL); return } Type guard
func isWithinLimit(n int64, max int64) bool { return n > 0 && n <= max } Try / catch
data, err := client.DownloadFile(ctx, url)
if err != nil {
if strings.Contains(err.Error(), "file exceeds maximum download size") {
return nil // skip large files gracefully
}
return err
} Prevention
- Check Content-Length or Notion file metadata size before downloading
- Exclude known-large file types (video, archives) from indexing
- Stream large files to disk instead of buffering if full download is required
When it happens
Trigger: Calling DownloadFile (via fetchPage while indexing) on an attachment whose content is larger than maxDownloadSize bytes, e.g. a large video, ZIP archive, or high-resolution image hosted by Notion.
Common situations: Notion workspaces that store large PDFs/videos/exports as page attachments; indexing a database containing file-type properties pointing at big uploads.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/96a8f80907397d1a.
Report an issue: GitHub.