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?