Inkdrop Fails to Start Due to Missing Note Reference

Bug Report: Inkdrop Fails to Start Due to Missing Note Reference

Summary

Inkdrop application becomes completely unusable when it tries to open a note that has been deleted from the database but is still referenced in the configuration file.

Environment

  • Application: Inkdrop
  • Platform: macOS
  • Config Location: ~/Library/Application Support/inkdrop/config.json
  • Error Type: 404 Not Found - Missing Note

Problem Description

When launching Inkdrop, the application fails to start properly and displays an error:

{
    "stack": "not_found: missing\n    at 62198 (/Applications/Inkdrop.app/Contents/Resources/app.asar/main-195.js:2:402957)\n    at s (/Applications/Inkdrop.app/Contents/Resources/app.asar/main.js:2:789146)\n    at 34214 (/Applications/Inkdrop.app/Contents/Resources/app.asar/main-214.js:1:221)\n    at Function.s (/Applications/Inkdrop.app/Contents/Resources/app.asar/main.js:2:789146)",
    "status": 404,
    "name": "not_found",
    "message": "missing",
    "error": true,
    "reason": "missing",
    "docId": "note:noYYkgRx"
}

This error prevents the user from accessing any functionality in the application.

Root Cause

The issue occurs when:

  1. A note (in this case note:noYYkgRx) is deleted from the database
  2. The note ID remains stored in config.json under lastNavigationState.editingNoteId
  3. On startup, Inkdrop attempts to load this non-existent note
  4. The 404 error blocks the entire application from functioning

Investigation Process

1. Verified Note Doesn’t Exist

curl -u username:password "http://localhost:19840/notes/note:noYYkgRx"
# Result: Not Found

2. Checked for References

Searched for the note ID in:

  • Bookmarks: Not found
  • Other notes linking to it: No references found
  • Recent notes list: Not present

3. Located Configuration Issue

grep -r "note:noYYkgRx" ~/Library/Application\ Support/inkdrop/
# Found in: ~/Library/Application Support/inkdrop/config.json

4. Identified Exact Location

grep -A2 -B2 "editingNoteId" ~/Library/Application\ Support/inkdrop/config.json
# Output:
#       },
#       "lastNavigationState": {
#         "editingNoteId": "note:noYYkgRx",
#         "queryContext": {
#           "mode": "all",

Solution

Quick Fix (Applied Successfully)

  1. Backup the configuration:

    cp ~/Library/Application\ Support/inkdrop/config.json ~/Library/Application\ Support/inkdrop/config.json.backup
    
  2. Set the editingNoteId to null:

    sed -i '' 's/"editingNoteId": "note:noYYkgRx"/"editingNoteId": null/g' ~/Library/Application\ Support/inkdrop/config.json
    
  3. Verify the change:

    grep -A2 -B2 "editingNoteId" ~/Library/Application\ Support/inkdrop/config.json
    
  4. Restart Inkdrop - the application now starts normally

Recommendations for Inkdrop Development Team

1. Graceful Error Handling

  • Implement a try-catch mechanism when loading the last edited note on startup
  • If a note is not found, fall back to a default view (e.g., All Notes) instead of blocking the entire application

2. Validation on Startup

// Pseudo-code example
async function loadLastEditingNote() {
  const config = loadConfig();
  const noteId = config.lastNavigationState?.editingNoteId;
  
  if (noteId) {
    try {
      await loadNote(noteId);
    } catch (error) {
      if (error.status === 404) {
        // Clear the invalid reference
        config.lastNavigationState.editingNoteId = null;
        saveConfig(config);
        // Load default view
        loadDefaultView();
      } else {
        throw error;
      }
    }
  }
}

3. Database Integrity Check

  • When deleting notes, ensure all references are cleaned up, including:
    • Navigation state
    • Bookmarks
    • Cross-references in other notes

4. Recovery Mode

  • Add a command-line flag or keyboard shortcut to start Inkdrop in “safe mode” without loading the last state
  • Example: inkdrop --safe-mode or holding Shift while starting

5. User-Friendly Error Display

  • Instead of showing a technical JSON error, display a user-friendly message:
    • “The note you were previously editing has been deleted. Loading your notes list instead.”

Steps to Reproduce

  1. Create a note in Inkdrop
  2. Close Inkdrop while that note is open
  3. Manually delete the note from the database (or corrupt the database)
  4. Try to reopen Inkdrop
  5. Application fails to start with 404 error

Impact

  • Severity: High - Application becomes completely unusable
  • User Experience: Very poor - User cannot access any of their notes
  • Data Loss: No - Notes are safe, only access is blocked

Workaround for Users

If encountering this issue:

  1. Close Inkdrop completely
  2. Navigate to ~/Library/Application Support/inkdrop/ (macOS)
  3. Edit config.json
  4. Find "editingNoteId": "note:XXXXX"
  5. Change it to "editingNoteId": null
  6. Save and restart Inkdrop

Report Date: June 29, 2025
Affected Version: Current release (as of June 2025)
Status: Workaround available, permanent fix needed

Hi @Dav_Mos ,

Thanks for reporting.

I tried to reproduce it by setting an incorrect note ID in core.lastNavigationState.editingNoteId, then I get this error screen, which is expected:

instead of what you reported like “The 404 error blocks the entire application from functioning”.

In my environment, it correctly tells you that the note does not exist, and you can select other notes :thinking:
So, it’s strange that the app fails to start with 404 error on your end.
Is it possible to share any stacktrace in the Developer Console?

I’m not actually following your answer, I never explicitly set any note id, that was implicit, not something I did.

But it’s blocking, I have to resort to the above procedure every time, and it’s really worrying to have to lose notes, that in some cases took hours to craft.

Sadly, this is blocking for me, I don’t want to leave this app, I’ve been a customer for probably 10 years, but I’m worried about losing hours of work each time.

Here is the stacktrack as required:

browser-main.js:2 Already opening note: note:D0HpCHH9
core:open-note @ browser-main.js:2
browser-main.js:2 Already opening note: note:D0HpCHH9
core:open-note @ browser-main.js:2
browser-main.js:2 Already opening note: note:D0HpCHH9
core:open-note @ browser-main.js:2
node:internal/modules/cjs/loader:1313 Uncaught (in promise) TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received ''
    at Module.require (node:internal/modules/cjs/loader:1313:11)
    at require (node:internal/modules/helpers:179:18)
    at loadConfig (/Users/davem/Library/Application Support/inkdrop/packages/move-notes/lib/inkdrop-move-notes.js:9:24)
    at Object.activate (/Users/davem/Library/Application Support/inkdrop/packages/move-notes/lib/inkdrop-move-notes.js:67:24)
    at v.activateNow (browser-main.js:2:624881)
    at browser-main.js:2:624341
    at v.measure (browser-main.js:2:622195)
    at browser-main.js:2:624200
    at new Promise (<anonymous>)
    at v.activate (browser-main.js:2:624142)
    at gd.activatePackage (browser-main.js:2:982897)
    at browser-main.js:2:982555
    at W.transactAsync (browser-main.js:2:661413)
    at gd.activatePackages (browser-main.js:2:982496)
    at gd.activate (browser-main.js:2:982228)
    at browser-main.js:2:684632
browser-main.js:2 app:error Unexpected error occurred: +0ms Object
a @ browser-main.js:2

Here is that object:

{
    "stack": "not_found: missing\n    at 62198 (/Applications/Inkdrop.app/Contents/Resources/app.asar/main-195.js:2:402957)\n    at s (/Applications/Inkdrop.app/Contents/Resources/app.asar/main.js:2:789146)\n    at 34214 (/Applications/Inkdrop.app/Contents/Resources/app.asar/main-214.js:1:221)\n    at Function.s (/Applications/Inkdrop.app/Contents/Resources/app.asar/main.js:2:789146)",
    "status": 404,
    "name": "not_found",
    "message": "missing",
    "error": true,
    "reason": "missing",
    "docId": "note:b3qk3n55"
}

The browser-main.js line is: e.packages.loadPackages(),

Try to disable/uninstall the move-notes plugin as the stacktrace indicates that the error occurs during the activation of this plugin.

Somehow the plugin is not able to load the config file: lib/inkdrop-move-notes.js#L9

2 Likes

Thanks Lukas, that fixed it.
I suggest you remove that plugin, I was about to move to Obsidian over this persistent blocking issue, out of fear of corrupting and losing 10 years of notes.

David