sillsdev / docu-notion

Download Notion pages as markdown and image files, preserving hierarchy and enabling workflow properties. Works with Docusaurus.
MIT License
150 stars 29 forks source link

Page needs to be public? #84

Open jellejurre opened 11 months ago

jellejurre commented 11 months ago

Describe the bug A clear and concise description of what the bug is. Error: Notion page not found thrown when site is not public It gets the first stage completely right, but fails at stage 2 This is resolved when publishing the page in Notion

Reproduction Steps Copy default template notion page to own page Add integration and key run npx @sillsdev/docu-notion -n [secret] -r [page_id]

Expected behavior The page is converted to docusaurus-friendly page

Screenshots 6007210ae8e045c9f96be3ec24f49bd0

Additional context This same error happened to #83 and it is resolved by making the site public, but since it doesnt have a specific bug report I thought i'd add it

hatton commented 11 months ago

There's something I'm missing; in my own test, the root pages do not have to be public, and that's what you'd expect-- you have to give your Notion "integration" explicit read permissions, so whether the Notion page is open to then world would seem irrelevant. Anyhow, obviously, there is something going on. In the meantime, I just changed the subject here so people would find it.

jellejurre commented 11 months ago

Just to make sure I'm not missing anything: full reproduction video

https://github.com/sillsdev/docu-notion/assets/76777936/4f2955ca-2bcd-4a96-83e2-f2a3f90241e0

(as for the secret: deleted the page and integration after)

opass commented 3 months ago

I met the same issue while following README steps.

I fixed it by removing the left and right columns block in "Notion Element Tests" page.

cirezd commented 3 months ago

I met the same issue while following README steps.

I fixed it by removing the left and right columns block in "Notion Element Tests" page.

That also works for me. Had the same issue using the template.

andrew-polk commented 3 months ago

This is indeed a bug in docu-notion. If you have any columns, you will get an error if the page is not public read. The reason is that we use an alternate notion client when trying to get the column width information because this info is not available from the official API, and, for some reason, to get the column info, you call getPage() with the column block ID.

Not sure what the best solution is. Probably to assume equal-width columns if we don't have access to the page and throw a warning into the log.

The current code in ColumnTransformer.ts:

// The official API doesn't give us access to the format information, including column_ratio.
// So we use 'notion-client' which uses the unofficial API.
// Once the official API gives us access to the format information, we can remove this
// and the 'notion-client' dependency.
// This logic was mostly taken from react-notion-x (sister project of notion-client).
async function getColumnWidth(
  block: ListBlockChildrenResponseResult
): Promise<string> {
  const unofficialNotionClient = new NotionAPI();
  const blockId = block.id;
  const recordMap = await executeWithRateLimitAndRetries(
    `unofficialNotionClient.getPage(${blockId}) in getColumnWidth()`,
    () => {
      // Yes, it is odd to call 'getPage' for a block, but that's how we access the format info.
      return unofficialNotionClient.getPage(blockId);
    }
  );
  const blockResult = recordMap.block[blockId];
  ...