[GH-ISSUE #2299] Import bookmarks from HTML file fails, when a folder name is not set #1403

Closed
opened 2026-03-02 11:57:04 +03:00 by kerem · 2 comments
Owner

Originally created by @Walhalla360 on GitHub (Dec 23, 2025).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/2299

Describe the Bug

I’ve just exported my entire bookmark chaos from Chrome/Brave and wanted to import it into Karakeep. At first I thought the import was being aborted immediately because of the number of bookmarks and folders, but based on Karakeep’s error message and the subsequent debugging via Chrome DevTools, I found out it was because I had a bookmark folder with no name.

Steps to Reproduce

  1. Go to http://localhost:3000/settings/import
  2. Click on "Import" and select the bookmarks HTML file
  3. See that the import gets immediately aborted and an error message is shown

Expected Behaviour

The bookmarks are imported normally after selecting the file. If the folder doesn’t have a name, it’s automatically replaced with “Unnamed.”

Screenshots or Additional Context

The error message:

Image

My debugging of the error:

Image Image

Here’s the corresponding snippet from the HTML file that causes the error.

<DT><H3 ADD_DATE="1765995928" LAST_MODIFIED="1765995928">Bluetooth Fernbedienung</H3> <DL><p> <DT><H3 ADD_DATE="1765995928" LAST_MODIFIED="0"></H3> <DL><p> <DT><A HREF="https://www.vocomo.de/de/bluetooth-fernbedienung-ble-media-button.html" ADD_DATE="1593444456" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABmklEQVR4nGzTuS9EURTH8WcssZf2JRMKW4QCIUNNJxSiU+jEnyAktDpLiYIIiUQhCoUtlkIUloLEEkPEVCL2wfie+D0ZZk7ymbx5795zz7nvPo8TGTUYwyHu5QjjqA0bF/P7o4jHIHqQ6kSPJ4yiD+9uAo8mz6JVA8+wgwBCyEQ9ivR8ER0IxmrAELp1PY8J3OIFD7jAKl5RjhIkYMUqqMIWkjCHJRTAryQW2bp3hRatbskbY9VPg1aZQi72sIwTnOMUcSjDASrUVsj696n0XSRq5TXtT4VKtut1VZCksTbHZwkKVWZAfd3gDV5cilf3/KokoDl5cU5khMKuv/79d5//vn6PVrDIQhA5qsTuF4tdx2t/PtW/hd8SbCpjnRLYbjfhQxt2qOsmPQtqrM3ZtJ9KbCMZC87P7meo32uVnC/WezPa8QyfvcY7pGiFUvV9jDSVmqXkj5rcptWHMe0eZdvMGWW2sDOxp+SOKrKPzKv/VmmntRb+MVmSAfQi3YkedqxH0K99+fM1ulGNLrXknhE7QBuYxH744G8AAAD//yR85PkAAAAGSURBVAMAoYRpJsO780EAAAAASUVORK5CYII=">VOCOMO - Bluetooth HiFi-Verstärker &amp; Freisprecheinrichtungen für BMW, VW, Mini, Ford, Opel nachrüsten - Bluetooth Fernbedienung (BLE Media Button)</A>

Device Details

Chrome 144.0.7559.31 beta (64-bit) on Windows 10

Exact Karakeep Version

v0.29.3

Have you checked the troubleshooting guide?

  • I have checked the troubleshooting guide and I haven't found a solution to my problem
Originally created by @Walhalla360 on GitHub (Dec 23, 2025). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/2299 ### Describe the Bug I’ve just exported my entire bookmark chaos from Chrome/Brave and wanted to import it into Karakeep. At first I thought the import was being aborted immediately because of the number of bookmarks and folders, but based on Karakeep’s error message and the subsequent debugging via Chrome DevTools, I found out it was because I had a bookmark folder with no name. ### Steps to Reproduce 1. Go to http://localhost:3000/settings/import 2. Click on "Import" and select the bookmarks HTML file 3. See that the import gets immediately aborted and an error message is shown ### Expected Behaviour The bookmarks are imported normally after selecting the file. If the folder doesn’t have a name, it’s automatically replaced with “Unnamed.” ### Screenshots or Additional Context The error message: <img width="541" height="173" alt="Image" src="https://github.com/user-attachments/assets/5f8c2f9e-27f4-44ff-b652-56d20679b705" /> My debugging of the error: <img width="850" height="359" alt="Image" src="https://github.com/user-attachments/assets/4e6a13a9-094e-4bf4-b8b6-a7a7e8c6047a" /> <img width="2607" height="610" alt="Image" src="https://github.com/user-attachments/assets/48f8c2c5-9af4-45d2-b367-1ff617b5cfb9" /> Here’s the corresponding snippet from the HTML file that causes the error. ` <DT><H3 ADD_DATE="1765995928" LAST_MODIFIED="1765995928">Bluetooth Fernbedienung</H3> <DL><p> <DT><H3 ADD_DATE="1765995928" LAST_MODIFIED="0"></H3> <DL><p> <DT><A HREF="https://www.vocomo.de/de/bluetooth-fernbedienung-ble-media-button.html" ADD_DATE="1593444456" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABmklEQVR4nGzTuS9EURTH8WcssZf2JRMKW4QCIUNNJxSiU+jEnyAktDpLiYIIiUQhCoUtlkIUloLEEkPEVCL2wfie+D0ZZk7ymbx5795zz7nvPo8TGTUYwyHu5QjjqA0bF/P7o4jHIHqQ6kSPJ4yiD+9uAo8mz6JVA8+wgwBCyEQ9ivR8ER0IxmrAELp1PY8J3OIFD7jAKl5RjhIkYMUqqMIWkjCHJRTAryQW2bp3hRatbskbY9VPg1aZQi72sIwTnOMUcSjDASrUVsj696n0XSRq5TXtT4VKtut1VZCksTbHZwkKVWZAfd3gDV5cilf3/KokoDl5cU5khMKuv/79d5//vn6PVrDIQhA5qsTuF4tdx2t/PtW/hd8SbCpjnRLYbjfhQxt2qOsmPQtqrM3ZtJ9KbCMZC87P7meo32uVnC/WezPa8QyfvcY7pGiFUvV9jDSVmqXkj5rcptWHMe0eZdvMGWW2sDOxp+SOKrKPzKv/VmmntRb+MVmSAfQi3YkedqxH0K99+fM1ulGNLrXknhE7QBuYxH744G8AAAD//yR85PkAAAAGSURBVAMAoYRpJsO780EAAAAASUVORK5CYII=">VOCOMO - Bluetooth HiFi-Verstärker &amp; Freisprecheinrichtungen für BMW, VW, Mini, Ford, Opel nachrüsten - Bluetooth Fernbedienung (BLE Media Button)</A>` ### Device Details Chrome 144.0.7559.31 beta (64-bit) on Windows 10 ### Exact Karakeep Version v0.29.3 ### Have you checked the troubleshooting guide? - [x] I have checked the troubleshooting guide and I haven't found a solution to my problem
kerem 2026-03-02 11:57:04 +03:00
Author
Owner

@MohamedBassem commented on GitHub (Dec 23, 2025):

@claude fix it

<!-- gh-comment-id:3687374580 --> @MohamedBassem commented on GitHub (Dec 23, 2025): @claude fix it
Author
Owner

@claude[bot] commented on GitHub (Dec 23, 2025):

Claude finished @MohamedBassem's task in 3m 3s —— View jobclaude/issue-2299-20251223-1711Create PR ➔


Fixing bookmark import issue with unnamed folders

I've successfully fixed the bug where importing bookmarks fails when a folder has no name.

Tasks

  • Understand repository structure and setup
  • Locate bookmark import HTML parsing code
  • Identify the bug causing the failure
  • Implement fix to handle empty folder names
  • Commit and push changes
  • Provide PR creation link

Root Cause

Found the issue in packages/shared/import-export/parsers.ts:58. When parsing HTML bookmark files, the code extracts folder names from <H3> tags. If the tag is empty (like <H3 ADD_DATE="1765995928" LAST_MODIFIED="0"></H3>), it adds an empty string to the path array, which later fails when trying to create a folder with an empty name.

Solution

Modified the parser to trim folder names and replace empty ones with "Unnamed" as suggested in the issue. Also added a comprehensive test case to ensure the fix works correctly.

Changes Made

  • packages/shared/import-export/parsers.ts: Added .trim() to folder names and replaced empty strings with "Unnamed"
  • packages/shared/import-export/importer.test.ts: Added test case that verifies HTML imports with empty folder names work correctly

The fix ensures that bookmarks can now be imported successfully even when the HTML file contains folders with no names. Empty folder names will automatically be replaced with "Unnamed" during the import process.

--- |

<!-- gh-comment-id:3687375064 --> @claude[bot] commented on GitHub (Dec 23, 2025): **Claude finished @MohamedBassem's task in 3m 3s** —— [View job](https://github.com/karakeep-app/karakeep/actions/runs/20467008075) • [`claude/issue-2299-20251223-1711`](https://github.com/karakeep-app/karakeep/tree/claude/issue-2299-20251223-1711) • [Create PR ➔](https://github.com/karakeep-app/karakeep/compare/main...claude/issue-2299-20251223-1711?quick_pull=1&title=fix%3A%20handle%20empty%20folder%20names%20in%20HTML%20bookmark%20imports&body=Fixes%20%232299%0A%0AThis%20PR%20fixes%20a%20bug%20where%20importing%20bookmarks%20from%20an%20HTML%20file%20would%20fail%20if%20the%20file%20contained%20folders%20with%20empty%20names.%0A%0A%23%23%20Changes%0A-%20Modified%20the%20HTML%20bookmark%20parser%20to%20trim%20folder%20names%20and%20replace%20empty%20ones%20with%20%22Unnamed%22%0A-%20Added%20test%20case%20to%20verify%20the%20fix%20works%20correctly%0A%0A%23%23%20Testing%0AThe%20new%20test%20case%20verifies%20that%3A%0A1.%20Empty%20H3%20tags%20in%20bookmark%20HTML%20files%20are%20handled%20gracefully%0A2.%20Folders%20with%20empty%20names%20are%20automatically%20renamed%20to%20%22Unnamed%22%0A3.%20Bookmarks%20are%20correctly%20placed%20in%20the%20folder%20hierarchy%0A%0AGenerated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.ai%2Fcode)) --- ### Fixing bookmark import issue with unnamed folders I've successfully fixed the bug where importing bookmarks fails when a folder has no name. ### Tasks - [x] Understand repository structure and setup - [x] Locate bookmark import HTML parsing code - [x] Identify the bug causing the failure - [x] Implement fix to handle empty folder names - [x] Commit and push changes - [x] Provide PR creation link ### Root Cause Found the issue in `packages/shared/import-export/parsers.ts:58`. When parsing HTML bookmark files, the code extracts folder names from `<H3>` tags. If the tag is empty (like `<H3 ADD_DATE="1765995928" LAST_MODIFIED="0"></H3>`), it adds an empty string to the path array, which later fails when trying to create a folder with an empty name. ### Solution Modified the parser to trim folder names and replace empty ones with "Unnamed" as suggested in the issue. Also added a comprehensive test case to ensure the fix works correctly. ### Changes Made - **packages/shared/import-export/parsers.ts**: Added `.trim()` to folder names and replaced empty strings with "Unnamed" - **packages/shared/import-export/importer.test.ts**: Added test case that verifies HTML imports with empty folder names work correctly The fix ensures that bookmarks can now be imported successfully even when the HTML file contains folders with no names. Empty folder names will automatically be replaced with "Unnamed" during the import process. --- |
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#1403
No description provided.