File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ export async function notionPull(options: DocuNotionOptions): Promise<void> {
5757 const optionsForLogging = { ...options } ;
5858 // Just show the first few letters of the notion token, which start with "secret" anyhow.
5959 optionsForLogging . notionToken =
60- optionsForLogging . notionToken . substring ( 0 , 3 ) + "..." ;
60+ optionsForLogging . notionToken . substring ( 0 , 10 ) + "..." ;
6161
6262 const config = await loadConfigAsync ( ) ;
6363
@@ -80,6 +80,24 @@ export async function notionPull(options: DocuNotionOptions): Promise<void> {
8080
8181 info ( "Connecting to Notion..." ) ;
8282
83+ // Do a quick test to see if we can connect to the root so that we can give a better error than just a generic "could not find page" one.
84+ try {
85+ await executeWithRateLimitAndRetries ( "retrieving root page" , async ( ) => {
86+ await notionClient . pages . retrieve ( { page_id : options . rootPage } ) ;
87+ } ) ;
88+ } catch ( e : any ) {
89+ error (
90+ `docu-notion could not retrieve the root page from Notion. \r\na) Check that the root page id really is "${
91+ options . rootPage
92+ } ".\r\nb) Check that your Notion API token (the "Integration Secret") is correct. It starts with "${
93+ optionsForLogging . notionToken
94+ } ".\r\nc) Check that your root page includes your "integration" in its "connections".\r\nThis internal error message may help:\r\n ${
95+ e . message as string
96+ } `
97+ ) ;
98+ exit ( 1 ) ;
99+ }
100+
83101 group (
84102 "Stage 1: walk children of the page named 'Outline', looking for pages..."
85103 ) ;
You can’t perform that action at this time.
0 commit comments