Skip to content

Commit 5baebe8

Browse files
committed
feat: Some checking and troubleshooting help for people just getting started
1 parent 24a7709 commit 5baebe8

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/pull.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff 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
);

0 commit comments

Comments
 (0)