{"record":{"id":"c47a3fe1082ef919","repo":"Tencent/WeKnora","slug":"w-s-c47a3f","errorCode":null,"errorMessage":"%w: %s","messagePattern":"%w: %s","errorType":"http","errorClass":null,"httpStatus":401,"severity":"error","filePath":"internal/datasource/connector/notion/client.go","lineNumber":114,"sourceCode":"\t\t\t\t\treturn nil, sErr\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\trespBody, err := io.ReadAll(resp.Body)\n\t\tresp.Body.Close()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"read response: %w\", err)\n\t\t}\n\n\t\tswitch {\n\t\tcase resp.StatusCode >= 200 && resp.StatusCode < 300:\n\t\t\treturn respBody, nil\n\n\t\tcase resp.StatusCode == 401 || resp.StatusCode == 403:\n\t\t\treturn nil, fmt.Errorf(\"%w: %s\", datasource.ErrInvalidCredentials, string(respBody))\n\n\t\tcase resp.StatusCode == 404:\n\t\t\treturn nil, fmt.Errorf(\"%w: %s\", datasource.ErrResourceNotFound, path)\n\n\t\tcase resp.StatusCode == 429:\n\t\t\tretryAfter := resp.Header.Get(\"Retry-After\")\n\t\t\twait := 1 * time.Second\n\t\t\tif secs, err := strconv.ParseFloat(retryAfter, 64); err == nil && secs > 0 {\n\t\t\t\twait = time.Duration(secs * float64(time.Second))\n\t\t\t}\n\t\t\tlogger.Warnf(ctx, \"[Notion] rate limited, retry after %v (attempt %d/%d)\", wait, attempt+1, maxRetries)\n\t\t\tlastErr = fmt.Errorf(\"rate limited: %s\", string(respBody))\n\t\t\tif attempt < maxRetries {\n\t\t\t\tif sErr := sleepWithContext(ctx, wait); sErr != nil {\n\t\t\t\t\treturn nil, sErr\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/datasource/connector/notion/client.go#L96-L132","documentation":"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.","triggerScenarios":"Thrown at internal/datasource/connector/notion/client.go:114 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate or update the Notion integration token","Confirm the token has access to the requested page/database","Do not retry — the credentials themselves are invalid"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}