Tencent/WeKnora · error

paginate %s: %w

Error message

paginate %s: %w

What it means

paginatePages wraps any failure from c.doRequest during cursor-based pagination of a Notion endpoint (path included for context). Any HTTP-level or API-level error (4xx/5xx from doRequest) surfaces as "paginate <endpoint>: <cause>".

Source

Thrown at internal/datasource/connector/notion/client.go:457

			"page_size": 100,
		}
		if startCursor != "" {
			body["start_cursor"] = startCursor
		}

		var respBody []byte
		var err error
		if method == http.MethodPost {
			respBody, err = c.doRequest(ctx, method, path, body)
		} else {
			p := path
			if startCursor != "" {
				p += "?start_cursor=" + startCursor + "&page_size=100"
			}
			respBody, err = c.doRequest(ctx, method, p, nil)
		}
		if err != nil {
			return nil, fmt.Errorf("paginate %s: %w", path, err)
		}

		var resp paginatedResponse
		if err := json.Unmarshal(respBody, &resp); err != nil {
			return nil, fmt.Errorf("unmarshal paginated response: %w", err)
		}

		var pages []notionPage
		if err := json.Unmarshal(resp.Results, &pages); err != nil {
			return nil, fmt.Errorf("unmarshal page results: %w", err)
		}

		for i := range pages {
			pages[i].Title = extractTitle(&pages[i])
		}

		allPages = append(allPages, pages...)

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Read the wrapped cause to identify the HTTP status / Notion error code
  2. Verify the integration token is valid and the database/page is shared with the integration
  3. Back off on 429s and retry; check Notion's rate limits
  4. Ensure the endpoint path is correct for the Notion API version

Example fix

// inspect cause
if errors.Is(err, datasource.ErrInvalidCredentials) { ... }
log.Printf("pagination failed: %v", err) // shows wrapped doRequest cause
Defensive patterns

Strategy: retry

Validate before calling

if !strings.HasPrefix(strings.TrimSpace(apiKey), "secret_") { return errors.New("invalid Notion token format") }

Try / catch

pages, err := client.SearchPages(ctx)
if err != nil {
    if strings.Contains(err.Error(), "paginate") && isRateLimited(err) {
        time.Sleep(backoff); retry()
    }
    return err
}

Prevention

When it happens

Trigger: doRequest returns an error while fetching a page of results from the search or database-query endpoint — invalid API key, rate limit, network error, or Notion returning an error payload.

Common situations: Invalid/revoked Notion integration token, Notion 429 rate-limit responses during large pagination loops, querying a database the integration has not been shared with (403).

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/922d2ea395eb6abf. Report an issue: GitHub.