Tencent/WeKnora · error

search notion pages: %w

Error message

search notion pages: %w

What it means

ListResources wraps any failure from client.SearchPages (the whole paginated Notion search used to discover pages the integration can access) with "search notion pages: %w". It signals that resource discovery itself failed, before any per-resource fetching starts.

Source

Thrown at internal/datasource/connector/notion/connector.go:83

	// Notion returns the full hierarchy (with parent_id populated) in a single
	// call, so children are already delivered with the root listing. Lazy-load
	// requests for a specific parent therefore have nothing extra to return.
	if parentID != "" {
		return []types.Resource{}, nil
	}

	notionCfg, err := parseNotionConfig(config)
	if err != nil {
		return nil, err
	}

	client, err := newClient(notionCfg.APIKey, extractBaseURL(config))
	if err != nil {
		return nil, err
	}
	pages, err := client.SearchPages(ctx)
	if err != nil {
		return nil, fmt.Errorf("search notion pages: %w", err)
	}

	allIDs := make(map[string]bool, len(pages))
	for _, p := range pages {
		allIDs[p.ID] = true
	}

	// Precompute effective parent for each page.
	// data_source objects need database_parent (their `parent` points at the
	// database container, not the workspace location); see resolveParentID.
	parentOf := make(map[string]string, len(pages))
	for _, p := range pages {
		if p.InTrash {
			continue
		}
		parentOf[p.ID] = resolveParentID(p, allIDs)
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Check the wrapped cause for auth vs network vs parse failure
  2. Validate the api_key credential (see ErrInvalidCredentials errors)
  3. Share the target pages/databases with the Notion integration in Notion UI
  4. Retry after backing off if the cause is 429/5xx

Example fix

pages, err := client.SearchPages(ctx)
if err != nil {
    log.Printf("notion discovery failed: %v", err) // see wrapped cause
    return nil, err
}
Defensive patterns

Strategy: try-catch

Validate before calling

if err := connector.Validate(ctx, config); err != nil { return err } // fail before discovery

Try / catch

resources, err := connector.ListResources(ctx, config)
if err != nil {
    if errors.Is(err, datasource.ErrInvalidCredentials) { return reconfigurePrompt }
    return fmt.Errorf("notion discovery failed: %w", err)
}

Prevention

When it happens

Trigger: SearchPages fails while ListResources is enumerating accessible pages — invalid API key, pagination error, unmarshal error, or network failure.

Common situations: Integration token not configured or revoked, no pages shared with the integration plus an API quirk, network outage during discovery, Notion rate limiting.

Related errors


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