zadam / trilium

Build your personal knowledge base with Trilium Notes
GNU Affero General Public License v3.0
27.2k stars 1.9k forks source link

(Bug report) "Hidden" note no longer hidden #3728

Closed nemec closed 1 year ago

nemec commented 1 year ago

Trilium Version

0.59.2

What operating system are you using?

macOS

What is your setup?

Local (no sync)

Operating System Version

macOS Monterey 12.6.3

Description

I got an error* after trying to upgrade to the latest version (0.59.2). I don't know what app version I was on originally. To fix it, I wrapped these lines in the migration script between if (hidden) { ... } and then built a copy of the Stable branch. The migration succeeded, but now I have a tree called "hidden" that... isn't. Any idea how to fix it?

Based on my attached logs, the note labeled "_hidden" was not created until after the database migration had completed (I guess it's been a while since I upgraded).

*Error from the original log, fixed now:

15:36:46.415 ERROR: error during migration to version 212: TypeError: Cannot read properties of undefined (reading 'getSubtreeNoteIds')
    at /Applications/Trilium Notes.app/Contents/Resources/app.asar/db/migrations/0212__delete_all_attributes_of_named_notes.js:11:37
    at /Applications/Trilium Notes.app/Contents/Resources/app.asar/node_modules/cls-hooked/context.js:118:13
    at Namespace.run (/Applications/Trilium Notes.app/Contents/Resources/app.asar/node_modules/cls-hooked/context.js:97:5)
    at Namespace.runAndReturn (/Applications/Trilium Notes.app/Contents/Resources/app.asar/node_modules/cls-hooked/context.js:117:8)
    at Object.init (/Applications/Trilium Notes.app/Contents/Resources/app.asar/src/services/cls.js:5:22)
    at module.exports (/Applications/Trilium Notes.app/Contents/Resources/app.asar/db/migrations/0212__delete_all_attributes_of_named_notes.js:6:9)
    at executeMigration (/Applications/Trilium Notes.app/Contents/Resources/app.asar/src/services/migration.js:85:9)
    at Function.<anonymous> (/Applications/Trilium Notes.app/Contents/Resources/app.asar/src/services/migration.js:56:17)
    at Function.sqliteTransaction (/Applications/Trilium Notes.app/Contents/Resources/app.asar/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
    at Object.transactional (/Applications/Trilium Notes.app/Contents/Resources/app.asar/src/services/sql.js:242:52)
15:36:46.416 ERROR: migration failed, crashing hard

Error logs

16:00:39.152 App db version is 213, while db version is 208. Migration needed. 16:00:39.159 DB size: 2420 KB 16:00:40.584 Trusted reverse proxy: false 16:00:40.585 App HTTP server starting up at port 37840 16:00:40.585 { "appVersion": "0.59.2", "dbVersion": 213, "syncVersion": 29, "buildDate": "2023-03-14T21:15:08+01:00", "buildRevision": "d8e9086bdeb721db795783b5d92395a9bd6882c9", "dataDirectory": ".../trilium-data", "clipperProtocolVersion": "1.0", "utcDateTime": "2023-03-16T21:00:39.144Z" } 16:00:40.587 CPU model: Apple 16:00:40.595 Listening on port 37840 16:00:41.607 Created backup at /Users/abc/Library/backup/trilium/backup-before-migration.db 16:00:41.610 Attempting migration to version 209 16:00:41.611 Migration to version 209 has been successful. 16:00:41.612 Attempting migration to version 210 16:00:41.632 Erased branches: ["XnHsICnEhjPd","BbvwJJrH247e","8tceA0hxS4An","0kjHDBijgKaO","JjkTMZli0WCp","GfoeCRb8KtKC","bFyTmqxLwaCy","FpYMfvmS0QwR","5qU72A503DBB","4i7BUC3j9rKu","JA8UyNUnzFo2","543HTRNnQZpF","L2T87lJFh3is","M0XacTs1XeLi","Yx4W7VpAcRX2","bM1MemdEZmDJ","wCGMCyUmhjf0","IqXAQ5wNmzeC","07QHzG3oLGBg","oXRs4QekSPup","M7C2tPWxZUun","keiluM9QPXHc","wz2oQYv2LLiB","ADetmWzqL40s","J1tiHKhCaRs0","5dybdBBInEXm","02Kjkm3pVuFi","xtz9jp1DoX6O","WliXUtioO1kI","NlrM0fUdkOGR","AAkibA2EzS3M","PCFNvgUyWR5G","HTTxgytQbfKk","CoFphmlhuX2B","xb1HIIYRBO8Z","BibhlEr1YtBp","ldl6Fkur4O1b","UfdNvt0sTAZ3","si0FmryVxPZb","PIjeW7NZxVRm","XII0LE8kTs5O","aQESCVH7arx0","4IdjL8HBTGts","utlzjFSRB0mS","VZCFWhiWB2gl"] 16:00:41.637 Erased attributes: ["mHk1VLmmydIJ","KGbVRP7F72Nu","cHoRKbcAmYHX","k7f2I3Cyp242","ExwI3udiP8Xe","l7UT0wsaL1iU","hxwVKGFhXStD","sCTHIhhJyHFv","UsIR0HBT98Bc","RhyKOsDSIFr2","pkgSUACgvVGS","C73Bb1tua13l","2qU18rgA7TFX","KFsR6audtbMx","TfOuq0BCZX2P","CBdiOUVqAMWO","XOHZvDTs5fV7","JOWQICVrl5pi","8WQDyvQB1Qg6","gGg5aj9oX6uS","X4o3ShYuQmYf","3xZCBEyez88Q","oqpytaB9hYLX","0pMi1nVJ7810","rcFtJAJa754j","mxdB7yJvkWA3","t4TKxvqVZGNc","HBEAJweav2gZ","bhjIop6AROHz","udlwOlFfmOag","tqtds3tlHrwx","LJJKJYkwmT46","yi6QnsoNekU2","B72UbYhin5a3","uekAsSL2H5NO","0PZweK72qgP7","bnxVqQ5L2kDU","VHTp2aiu74tq","2hhiBbWuHphs","2q3OJX3OISeD","BbQmeyXVGXbN","Ba1HROL8sDTT","4CxrTCzjXgHG","K4llWiWHltJr","x8Oh6nDzxAlL","UkHwmhJrPGnd","SOZzTnAWo7tf","M99lxxg21dXz","1gnLxIWP2Ez9","gBSp2vIBAp12","kc0Nm65Xovkl","aoiCkyVwKS9n","It5cIH7YU1Y4","Po3F0H7xCDs8","inNIhsZMyUMD","QL5XsRlnyP4y","c77gH3yJphy1","KZgDzqH7l1w6","MQrBiilsKmrG","1E8N6nL5ZwAj","x7BH76gObGE8","XWShOWFlJ0Nc","k9lKSzK5o66b","y9bjckVK5kF3","XKxUSX5RPBv1","t50dZ7v2V20K","HOb4ugECNyBp","ohMYYGIk31Kv","YhVNERvlTfV6","GcTm9F2Srhf5","RpnWwXngtvfk","6mg3lal1IrWs","TaKCaXAWiHnY","fKPgJKhTzhnO","wiIoeQenmAFA","22hRnFMvM9Nh","vOMU8mBltd1X","n5btsDbxxCmq","aAxNmhbJiVxs","56TAl3DqwvIx","53wFvA1d8Yvp","7FGP14oiPg4E","HtuQrLN1DSvn","flXFC6WL2kW1","FgSiPI9t5EyE","Eb14VXaqw3pp","AaBrerOsW69L","0TP3XQhGUk0I","MB1BEBqq2y0X","tvPwuimtlFLv","fZlQap6b9ttX","mHMZPkk4TlI2","2lZC78pqEcdI","62toZN81yjqw"] 16:00:41.637 Erased notes: ["EvQC8fb30zRv","BXzUAENAacny","Le8Nt2RRjo99","EL2jnybqBWsq","CzvHsLf1BxoF","x0ghYvBfpS77","1sjnJAfrtIZh","AveV7amb0WG2","7wwgtjsyU0XO","ICnzLQ0TY5Ek","uhNEDXY9s44p","uqmRnnOddswt","fCkdceTqZDF2","Bz141gMBnkXW","1q9pqhVEmix3","HanlQYU5b6Eq","xN0hLKuHFIxG","SccStPf8XSwd","ZtxmBxhGEzy4","xPU632O3YlmI","LmK7vXm2IQjX","tuWoJVe8LXEQ","OChQjAvNVqA1","CatB2CQqx1zD","X4PEuGU9xjwz","BeJnB1g0qFJ4","tGHWVso5ohkG","oZOc3ZaaJgGP","qR9EVE0Yp3QM","uKDHF2hIAyZY","DHwiHFsUq3Ij","TfhXuBFteLpc","f0zIGY5uzswO","Zn2CCeHxBnYl","JOC03XRgaBO5","NhVd0wfiReJI","XVg6yNPn18Lr","BUhVjFJVTyEn","nu3JeqL14Znm","N2Hpt3tAiAyE","xQqJxQT53Mny","WqKZEjWCKSAf","NVsmYLN8LkDG","IGqIo8ufJcSn"] 16:00:41.639 Erased branches: ["loGiXYiRdpYk"] 16:00:41.651 Becca (note cache) load took 12ms 16:00:41.653 Table counts: notes: 230, note_revisions: 106, branches: 239, attributes: 338, etapi_tokens: 1 16:00:41.662 Migration to version 210 has been successful. 16:00:41.663 Attempting migration to version 211 16:00:41.667 Migration to version 211 has been successful. 16:00:41.667 Attempting migration to version 212 16:00:41.678 Becca (note cache) load took 6ms 16:00:41.678 Migration to version 212 has been successful. 16:00:41.678 Attempting migration to version 213 16:00:41.682 Becca (note cache) load took 3ms 16:00:41.683 Replacing legacy API calls for note '9te0jAigPdKe' 16:00:41.694 Replacing legacy API calls for note 'XaXLTShK9EGB' 16:00:41.699 Migration to version 213 has been successful. 16:00:41.723 Becca (note cache) load took 19ms 16:00:41.738 Created new note '_hidden', branch 'roothidden' of type 'doc', mime '' 16:00:41.747 Created new note '_search', branch '_hiddensearch' of type 'doc', mime '' 16:00:41.751 Created new note '_globalNoteMap', branch '_hiddenglobalNoteMap' of type 'noteMap', mime '' 16:00:41.754 Created new note '_sqlConsole', branch '_hiddensqlConsole' of type 'doc', mime '' 16:00:41.757 Created new note '_share', branch '_hiddenshare' of type 'doc', mime '' 16:00:41.760 Created new note '_bulkAction', branch '_hiddenbulkAction' of type 'doc', mime '' 16:00:41.761 Created new note '_backendLog', branch '_hiddenbackendLog' of type 'contentWidget', mime '' 16:00:41.767 Created new note '_userHidden', branch '_hiddenuserHidden' of type 'doc', mime '' 16:00:41.771 Created new note '_lbTplRoot', branch '_hiddenlbTplRoot' of type 'doc', mime '' 16:00:41.776 Created new note '_lbTplBase', branch '_lbTplRootlbTplBase' of type 'doc', mime '' 16:00:41.780 Created new note '_lbTplCommandLauncher', branch '_lbTplRootlbTplCommandLauncher' of type 'doc', mime '' 16:00:41.785 Created new note '_lbTplNoteLauncher', branch '_lbTplRootlbTplNoteLauncher' of type 'doc', mime '' 16:00:41.791 Created new note '_lbTplScriptLauncher', branch '_lbTplRootlbTplScriptLauncher' of type 'doc', mime '' 16:00:41.793 Created new note '_lbTplBuiltinWidget', branch '_lbTplRootlbTplBuiltinWidget' of type 'doc', mime '' 16:00:41.797 Created new note '_lbTplSpacer', branch '_lbTplRootlbTplSpacer' of type 'doc', mime '' 16:00:41.803 Created new note '_lbTplCustomWidget', branch '_lbTplRootlbTplCustomWidget' of type 'doc', mime '' 16:00:41.805 Created new note '_lbRoot', branch '_hiddenlbRoot' of type 'doc', mime '' 16:00:41.809 Created new note '_lbAvailableLaunchers', branch '_lbRootlbAvailableLaunchers' of type 'doc', mime '' 16:00:41.819 Created new note '_lbBackInHistory', branch '_lbAvailableLauncherslbBackInHistory' of type 'launcher', mime '' 16:00:41.821 Created new note '_lbForwardInHistory', branch '_lbAvailableLauncherslbForwardInHistory' of type 'launcher', mime '' 16:00:41.827 Created new note '_lbBackendLog', branch '_lbAvailableLauncherslbBackendLog' of type 'launcher', mime '' 16:00:41.829 Created new note '_lbVisibleLaunchers', branch '_lbRootlbVisibleLaunchers' of type 'doc', mime '' 16:00:41.831 Created new note '_lbNewNote', branch '_lbVisibleLauncherslbNewNote' of type 'launcher', mime '' 16:00:41.837 Created new note '_lbSearch', branch '_lbVisibleLauncherslbSearch' of type 'launcher', mime '' 16:00:41.838 Created new note '_lbJumpTo', branch '_lbVisibleLauncherslbJumpTo' of type 'launcher', mime '' 16:00:41.839 Created new note '_lbNoteMap', branch '_lbVisibleLauncherslbNoteMap' of type 'launcher', mime '' 16:00:41.840 Created new note '_lbCalendar', branch '_lbVisibleLauncherslbCalendar' of type 'launcher', mime '' 16:00:41.841 Created new note '_lbRecentChanges', branch '_lbVisibleLauncherslbRecentChanges' of type 'launcher', mime '' 16:00:41.843 Created new note '_lbSpacer1', branch '_lbVisibleLauncherslbSpacer1' of type 'launcher', mime '' 16:00:41.844 Created new note '_lbBookmarks', branch '_lbVisibleLauncherslbBookmarks' of type 'launcher', mime '' 16:00:41.845 Created new note '_lbToday', branch '_lbVisibleLauncherslbToday' of type 'launcher', mime '' 16:00:41.851 Created new note '_lbSpacer2', branch '_lbVisibleLauncherslbSpacer2' of type 'launcher', mime '' 16:00:41.857 Created new note '_lbProtectedSession', branch '_lbVisibleLauncherslbProtectedSession' of type 'launcher', mime '' 16:00:41.858 Created new note '_lbSyncStatus', branch '_lbVisibleLauncherslbSyncStatus' of type 'launcher', mime '' 16:00:41.859 Created new note '_options', branch '_hiddenoptions' of type 'book', mime '' 16:00:41.861 Created new note '_optionsAppearance', branch '_optionsoptionsAppearance' of type 'contentWidget', mime '' 16:00:41.863 Created new note '_optionsShortcuts', branch '_optionsoptionsShortcuts' of type 'contentWidget', mime '' 16:00:41.864 Created new note '_optionsTextNotes', branch '_optionsoptionsTextNotes' of type 'contentWidget', mime '' 16:00:41.864 Created new note '_optionsCodeNotes', branch '_optionsoptionsCodeNotes' of type 'contentWidget', mime '' 16:00:41.865 Created new note '_optionsImages', branch '_optionsoptionsImages' of type 'contentWidget', mime '' 16:00:41.866 Created new note '_optionsSpellcheck', branch '_optionsoptionsSpellcheck' of type 'contentWidget', mime '' 16:00:41.867 Created new note '_optionsPassword', branch '_optionsoptionsPassword' of type 'contentWidget', mime '' 16:00:41.868 Created new note '_optionsEtapi', branch '_optionsoptionsEtapi' of type 'contentWidget', mime '' 16:00:41.869 Created new note '_optionsBackup', branch '_optionsoptionsBackup' of type 'contentWidget', mime '' 16:00:41.869 Created new note '_optionsSync', branch '_optionsoptionsSync' of type 'contentWidget', mime '' 16:00:41.871 Created new note '_optionsOther', branch '_optionsoptionsOther' of type 'contentWidget', mime '' 16:00:41.871 Created new note '_optionsAdvanced', branch '_options__optionsAdvanced' of type 'contentWidget', mime '' 16:00:42.375 Registered global shortcut Meta+Alt+P for action createNoteIntoInbox 16:00:42.835 Generated CSRF token abc with secret _csrf=abc; Path=/ 16:00:44.299 200 GET /api/options with 5759 bytes took 1ms 16:00:44.307 200 GET /api/tree with 19853 bytes took 3ms 16:00:44.319 200 GET /api/keyboard-actions with 12149 bytes took 2ms 16:00:44.327 200 GET /api/script/widgets with 2687 bytes took 1ms 16:00:44.660 200 POST /api/tree/load with 4161 bytes took 2ms 16:00:45.095 200 GET /api/keyboard-shortcuts-for-notes with 2 bytes took 1ms 16:00:45.227 200 POST /api/tree/load with 5886 bytes took 0ms 16:00:45.740 Table counts: notes: 277, note_revisions: 108, branches: 286, attributes: 443, etapi_tokens: 1 16:00:45.746 All consistency checks passed with no errors detected (took 7ms) 16:00:45.820 200 POST /api/tree/load with 18192 bytes took 1ms 16:00:46.646 200 GET /api/notes/0one7AopHRZn with 2021 bytes took 1ms 16:00:46.648 200 GET /api/note-map/0one7AopHRZn/backlink-count with 11 bytes took 1ms 16:00:48.578 200 GET /api/script/startup with 2176 bytes took 2ms 16:00:48.584 200 POST /api/tree/load with 2689 bytes took 1ms 16:00:48.608 Created new note 'tb_today', branch '_lbVisibleLaunchers_tb_today' of type 'launcher', mime '' 16:00:48.614 Slow 200 PUT /api/special-notes/api-script-launcher with 318 bytes took 10ms 16:00:48.616 200 POST /api/tree/load with 2944 bytes took 0ms 16:00:48.618 200 POST /api/tree/load with 5125 bytes took 1ms 16:00:48.622 Created new note 'tb_newtask', branch '_lbVisibleLaunchers_tb_newtask' of type 'launcher', mime '' 16:00:48.625 200 PUT /api/special-notes/api-script-launcher with 323 bytes took 5ms 16:00:48.629 200 POST /api/tree/load with 9196 bytes took 1ms 16:00:48.631 200 POST /api/tree/load with 9196 bytes took 1ms 16:00:48.661 200 POST /api/tree/load with 9200 bytes took 1ms 16:00:48.664 200 POST /api/tree/load with 9200 bytes took 1ms 16:02:32.032 200 GET /api/tree?subTreeNoteId=hidden with 8205 bytes took 3ms 16:02:32.753 204 PUT /api/branches/root_hidden/expanded/1 with 0 bytes took 1ms 16:02:39.440 200 GET /api/note-map/hidden/backlink-count with 11 bytes took 1ms 16:02:39.517 204 PUT /api/options with 0 bytes took 3ms 16:02:44.302 200 GET /api/note-map/backendLog/backlink-count with 11 bytes took 1ms 16:02:44.314 204 PUT /api/options with 0 bytes took 1ms 16:02:46.619 200 GET /api/note-map/search/backlink-count with 11 bytes took 0ms 16:02:46.631 204 PUT /api/options with 0 bytes took 0ms 16:02:47.696 200 GET /api/note-map/bulkAction/backlink-count with 11 bytes took 0ms 16:02:47.705 204 PUT /api/options with 0 bytes took 1ms 16:03:35.380 200 GET /api/note-map/hidden/backlink-count with 11 bytes took 1ms 16:03:35.400 204 PUT /api/options with 0 bytes took 1ms 16:03:36.714 200 GET /api/note-map/globalNoteMap/backlink-count with 11 bytes took 2ms 16:03:36.775 204 PUT /api/options with 0 bytes took 0ms 16:03:37.043 Slow 200 POST /api/note-map/root/link with 14425 bytes took 25ms 16:03:37.843 200 GET /api/note-map/hidden/backlink-count with 11 bytes took 1ms 16:03:37.864 204 PUT /api/options with 0 bytes took 1ms 16:05:53.873 200 GET /api/app-info with 300 bytes took 2ms

zadam commented 1 year ago

Hello, thanks for the heads-up. It's a bit strange since the migration 200 should have created the hidden subtree. But maybe it got deleted in the meantime?

Anyway, you found a way around it and the app recovered - the hidden subtree is checked on every startup and created if it doesn't exist, so that's fine.

I've put the check for hidden subtree existence into the migration for the case that something similar will happen for other people.

nemec commented 1 year ago

Is the subtree supposed to be visible in the app, though? Or maybe I misunderstand the meaning of "hidden" in this context 😄

zadam commented 1 year ago

Could you please post a screenshot of the structure of your "hidden" note which is visible? Something like this?

image

nemec commented 1 year ago
2023-03-17_16-55-27 2023-03-17_16-52-31 2023-03-17_16-53-03
zadam commented 1 year ago

Thanks.

Except for the name ("hidden" is old name, should have been automatically renamed to "Hidden Notes") it looks correct. Also, the fact that it's not actually hidden as it should. Not sure why :-(

nemec commented 1 year ago

Ok, I'm fine with it being visible if it's otherwise working correctly. I appreciate the help!