trilium icon indicating copy to clipboard operation
trilium copied to clipboard

(Bug report) consistency check breaks search for protected notes

Open Nriver opened this issue 1 year ago • 4 comments

Trilium Version

0.59.1

What operating system are you using?

Other Linux

What is your setup?

Local + server sync

Operating System Version

Manjaro

Description

My protected notes can note be searched anymore. It just throw an error.

ERROR: get /api/quick-search/:searchString threw exception: 'Cannot read properties of null (reading 'toString')', stack: TypeError: Cannot read properties of null (reading 'toString')
   at NoteContentFulltextExp.preprocessContent (/opt/trilium-cn/resources/app.asar/src/services/search/expressions/note_content_fulltext.js:105:43)
   at NoteContentFulltextExp.findInText (/opt/trilium-cn/resources/app.asar/src/services/search/expressions/note_content_fulltext.js:72:24)
   at NoteContentFulltextExp.execute (/opt/trilium-cn/resources/app.asar/src/services/search/expressions/note_content_fulltext.js:48:18)
   at OrExp.execute (/opt/trilium-cn/resources/app.asar/src/services/search/expressions/or.js:32:49)
   at AndExp.execute (/opt/trilium-cn/resources/app.asar/src/services/search/expressions/and.js:26:42)
   at findResultsWithExpression (/opt/trilium-cn/resources/app.asar/src/services/search/services/search.js:155:32)
   at Object.findResultsWithQuery (/opt/trilium-cn/resources/app.asar/src/services/search/services/search.js:254:12)
   at quickSearch (/opt/trilium-cn/resources/app.asar/src/routes/api/search.js:61:41)
   at Function.cb (/opt/trilium-cn/resources/app.asar/src/routes/routes.js:409:34)
   at Function.sqliteTransaction (/opt/trilium-cn/resources/app.asar/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)

JS Error: 500 GET /api/quick-search/test - Cannot read properties of null (reading 'toString')
Stack: Error
   at Object.N [as logError] (http://127.0.0.1:37840/assets/v0.59.1/app-dist/desktop.js:2:101211)
   at Object.throwError (http://127.0.0.1:37840/assets/v0.59.1/app-dist/desktop.js:2:86320)
   at h (http://127.0.0.1:37840/assets/v0.59.1/app-dist/desktop.js:2:82301)
   at async EventEmitter.<anonymous> (http://127.0.0.1:37840/assets/v0.59.1/app-dist/desktop.js:2:83170)

Here is the code goes wrong. It invokes a toString() function. code0

After some debug, I get the bad note ID. Searched the data in the database. db

The date leads me to this code for consistency check. code1

The default value for the protected notes is null. code2

Appearently, you can not invoke toString() for that.

Error logs

No response

Nriver avatar Mar 06 '23 02:03 Nriver

Hello, could you check your logs for "content was set to empty string since there was no corresponding row" to see if this really happened to this note?

zadam avatar Mar 06 '23 22:03 zadam

I'll check it later as I use trilium on several different computers, couldn't recall which one caused this.

Nriver avatar Mar 07 '23 02:03 Nriver

Found it in the log several days ago. The note id matches.

log

I think I was putting a dozen of images into Trilium and happens to make two client sync at the same time when the network was not very good. I cancelled the sync before it finished, and later there were some images get broken. Then I turned to consistent check.

Nriver avatar Mar 07 '23 11:03 Nriver

I see, good to have it confirmed that this was indeed the source of the bug. Thanks for the investigation.

zadam avatar Mar 07 '23 21:03 zadam

close for solved

Nriver avatar May 18 '23 03:05 Nriver