Tencent/WeKnora · error

%w: %s

Error message

%w: %s

What it means

Notion API returned HTTP 401 or 403 in doRequest; the error wraps datasource.ErrInvalidCredentials with the response body, meaning the integration token is missing, revoked, or lacks access to the target resource.

Source

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

					return nil, sErr
				}
				continue
			}
			break
		}

		respBody, err := io.ReadAll(resp.Body)
		resp.Body.Close()
		if err != nil {
			return nil, fmt.Errorf("read response: %w", err)
		}

		switch {
		case resp.StatusCode >= 200 && resp.StatusCode < 300:
			return respBody, nil

		case resp.StatusCode == 401 || resp.StatusCode == 403:
			return nil, fmt.Errorf("%w: %s", datasource.ErrInvalidCredentials, string(respBody))

		case resp.StatusCode == 404:
			return nil, fmt.Errorf("%w: %s", datasource.ErrResourceNotFound, path)

		case resp.StatusCode == 429:
			retryAfter := resp.Header.Get("Retry-After")
			wait := 1 * time.Second
			if secs, err := strconv.ParseFloat(retryAfter, 64); err == nil && secs > 0 {
				wait = time.Duration(secs * float64(time.Second))
			}
			logger.Warnf(ctx, "[Notion] rate limited, retry after %v (attempt %d/%d)", wait, attempt+1, maxRetries)
			lastErr = fmt.Errorf("rate limited: %s", string(respBody))
			if attempt < maxRetries {
				if sErr := sleepWithContext(ctx, wait); sErr != nil {
					return nil, sErr
				}
				continue
			}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Regenerate or update the Notion integration token
  2. Confirm the token has access to the requested page/database
  3. Do not retry — the credentials themselves are invalid
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/datasource/connector/notion/client.go:114 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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