Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError #3

Open
techyogi opened this issue Feb 4, 2022 · 4 comments
Open

KeyError #3

techyogi opened this issue Feb 4, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@techyogi
Copy link

techyogi commented Feb 4, 2022

trying to pull an entire workspace, so using the pageid of the workspace page. Always getting "KeyError" as follows:

2022-02-04 09:29:32,033 INFO: 馃 Notion authentification completed successfully.
2022-02-04 09:29:32,034 INFO: 馃 Started raw notion content parsing.
2022-02-04 09:29:38,845 INFO: 馃 Downloaded raw notion content. Saved at ./notion_content.json
2022-02-04 09:29:38,845 INFO: 馃 Started structuring notion data
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/techyogi/Desktop/notion4ever/notion4ever/main.py", line 102, in
main()
File "/Users/techyogi/Desktop/notion4ever/notion4ever/main.py", line 74, in main
structured_notion = structuring.structurize_notion_content(raw_notion,
File "/Users/techyogi/Desktop/notion4ever/notion4ever/structuring.py", line 495, in structurize_notion_content
markdown_parser.parse_markdown(raw_notion, structured_notion)
File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 372, in parse_markdown
page_md = blocks_convertor(raw_notion[page_id]["blocks"], structured_notion, page_id)
File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 139, in blocks_convertor
block_md = block_convertor(block,0, structured_notion, page_id)
File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 238, in block_convertor
block_md = block_convertor(block, depth, structured_notion, page_id)
File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 238, in block_convertor
block_md = block_convertor(block, depth, structured_notion, page_id)
File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 188, in block_convertor
title = structured_notion['pages'][block['id']]['title']
KeyError: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'

@MerkulovDaniil
Copy link
Owner

Indeed, the code was designed to work with some specific page with all nested content inside the page. Need to add the option for exporting the whole workspace.

@MerkulovDaniil MerkulovDaniil added the enhancement New feature or request label Feb 6, 2022
@Kourai
Copy link

Kourai commented Jun 21, 2022

Hello ! Kind of a similar problem here :
I tryied to pull a regular page (no subpage, no database)
But I'm also getting a "KeyError'

2022-06-21 19:13:06,788 INFO: 馃 Started structuring notion data
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/runner/work/notionexport/notionexport/notion4ever/main.py", line 109, in
main()
File "/home/runner/work/notionexport/notionexport/notion4ever/main.py", line 81, in main
structured_notion = structuring.structurize_notion_content(raw_notion,
File "/home/runner/work/notionexport/notionexport/notion4ever/structuring.py", line 500, in structurize_notion_content
markdown_parser.parse_markdown(raw_notion, structured_notion)
File "/home/runner/work/notionexport/notionexport/notion4ever/markdown_parser.py", line 376, in parse_markdown
page_md = blocks_convertor(raw_notion[page_id]["blocks"], structured_notion, page_id)
File "/home/runner/work/notionexport/notionexport/notion4ever/markdown_parser.py", line 140, in blocks_convertor
block_md = block_convertor(block,0, structured_notion, page_id)
File "/home/runner/work/notionexport/notionexport/notion4ever/markdown_parser.py", line 239, in block_convertor
block_md = block_convertor(block, depth, structured_notion, page_id)
File "/home/runner/work/notionexport/notionexport/notion4ever/markdown_parser.py", line 239, in block_convertor
block_md = block_convertor(block, depth, structured_notion, page_id)
File "/home/runner/work/notionexport/notionexport/notion4ever/markdown_parser.py", line 206, in block_convertor
block_type_map[block_type](information_collector(block[block_type],
File "/home/runner/work/notionexport/notionexport/notion4ever/markdown_parser.py", line 151, in information_collector
information['icon'] = payload['icon']['emoji']
KeyError: 'emoji'
Error: Process completed with exit code 1.

I Guess the culprit is quite obvious here : THE EMOJI !
I had a custom emoji on the page (Added by using the Upload/Link function from notion emoji), and now it run fine ! ;)

@Frekido
Copy link

Frekido commented Oct 26, 2022

Dear MerkuloDanii, First of all, thank for this nice project!
I also have a KeyError.
Have you allready found a way to export the whole workspace, without heving to specify a Page_id?
Thanks!

@asmodat
Copy link

asmodat commented Dec 21, 2022

The same issue found here:

2022-12-21 07:[11](https://github.com/KiraCore/docs.kira.network/actions/runs/3747180944/jobs/6363161943#step:9:12):17,725 INFO: 馃 Notion authentification completed successfully.
2022-[12](https://github.com/KiraCore/docs.kira.network/actions/runs/3747180944/jobs/6363161943#step:9:13)-21 07:11:17,725 INFO: 馃 Started raw notion content parsing.
2022-12-21 07:11:18,468 INFO: 馃 Downloaded raw notion content. Saved at ./notion_content.json
2022-12-21 07:11:18,468 INFO: 馃 Started structuring notion data
Traceback (most recent call last):
  File "/__t/Python/3.10.0/x64/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/__t/Python/3.10.0/x64/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/__w/docs.kira.network/docs.kira.network/notion4ever/__main__.py", line 109, in <module>
    main()
  File "/__w/docs.kira.network/docs.kira.network/notion4ever/__main__.py", line 81, in main
    structured_notion = structuring.structurize_notion_content(raw_notion,
  File "/__w/docs.kira.network/docs.kira.network/notion4ever/structuring.py", line 489, in structurize_notion_content
    structured_notion["pages"] = parse_headers(raw_notion)
  File "/__w/docs.kira.network/docs.kira.network/notion4ever/structuring.py", line [16](https://github.com/KiraCore/docs.kira.network/actions/runs/3747180944/jobs/6363161943#step:9:17)3, in parse_headers
    notion_pages[parent_id]["children"].append(page_id)
KeyError: 'b6[17](https://github.com/KiraCore/docs.kira.network/actions/runs/3747180944/jobs/6363161943#step:9:18)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSANITIZEDXXXXXXXXXXXXX'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants