joplin icon indicating copy to clipboard operation
joplin copied to clipboard

Decryption worker fails if a resource has its metadata decrypted but not its content

Open laurent22 opened this issue 1 year ago • 9 comments

Operating system

Windows

Joplin version

2.13

Desktop version info

No response

Current behaviour

2022-03-30 20:43:57: "DecryptionWorker: starting decryption..."
2022-03-30 20:43:57: "DecryptionWorker: error for: d1af6cff695c45a6938be6432378eef0 (resources)", "Error: json decode: this isn't json!
Error: json decode: this isn't json!
    at EncryptionService.<anonymous> (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/@joplin/lib/services/e2ee/EncryptionService.js:387:23)
    at Generator.next (<anonymous>)
    at /Applications/Joplin.app/Contents/Resources/app.asar/node_modules/@joplin/lib/services/e2ee/EncryptionService.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/@joplin/lib/services/e2ee/EncryptionService.js:4:12)
    at EncryptionService.decrypt (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/@joplin/lib/services/e2ee/EncryptionService.js:368:16)
    at EncryptionService.<anonymous> (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/@joplin/lib/services/e2ee/EncryptionService.js:442:46)
    at Generator.next (<anonymous>)
    at fulfilled (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/@joplin/lib/services/e2ee/EncryptionService.js:5:58)", "{"id":"d1af6cff695c45a6938be6432378eef0","title":"title.pdf","mime":"application/pdf","filename":"","created_time":1643304903133,"updated_time":1643304903133,"user_created_time":1643304903133,"user_updated_time":1643304903133,"file_extension":"pdf","encryption_cipher_text":"","encryption_applied":0,"encryption_blob_encrypted":1,"size":599368,"is_shared":0,"share_id":"","master_key_id":"","type_":4}"
{
    "id": "d1af6cff695c45a6938be6432378eef0",
    "title": "title.pdf",
    "mime": "application/pdf",
    "filename": "",
    "created_time": 1643304903133,
    "updated_time": 1643304903133,
    "user_created_time": 1643304903133,
    "user_updated_time": 1643304903133,
    "file_extension": "pdf",
    "encryption_cipher_text": "",
    "encryption_applied": 0,
    "encryption_blob_encrypted": 1,
    "size": 599368,
    "is_shared": 0,
    "share_id": "",
    "master_key_id": "",
    "type_": 4
}

Looks like the decryption worker attempts to decrypt the metadata, even though it's already decrypted. However the resource content is still encrypted ("encryption_blob_encrypted":1) so it should process this.

Expected behaviour

No response

Logs

No response

laurent22 avatar Feb 08 '24 17:02 laurent22

Adding details as per @laurent22's request.

tydel@mbp resources % pwd
/Users/tydel/.config/joplin-desktop/resources
tydel@mbp resources % ls -l | grep 9c8a
-rw-r--r--  1 tydel  staff    130162  9 Feb  2022 5338208f82b34b7ab91f0aabcc439c8a.crypted

5338208f82b34b7ab91f0aabcc439c8a.zip

tydel avatar Feb 08 '24 20:02 tydel

I see that the file is actually truncated. What do you sync with?

(Edit: think/sync)

laurent22 avatar Feb 08 '24 21:02 laurent22

I see that the file is actually truncated. What do you sync with?

Dropbox.

tydel avatar Feb 09 '24 00:02 tydel

Hmm, this is strange, normally downloads are atomic so either we get the whole file or nothing at all, but a truncated file I haven't seen that before. Is there something special to your network like a proxy or vpn filtering the data?

laurent22 avatar Feb 09 '24 12:02 laurent22

Or are you using a mobile device?

Because if you forgot to babysit the sync and your phone went into screensaver then it might lead to the sync being killed in-between as there's no background sync available as it is known in other note taking apps.

That's usually the cause of conflicts in my case (if you don't do the active babysitting very regularly) and it might have caused a similar issue in my database.

I am also using Dropbox by the way.

I have a few thousand notes and a full sync needs a long time babysitting.

I probably lost a few days of my life just babysitting Joplin notes now 😄

alexanderadam avatar Feb 09 '24 12:02 alexanderadam

No that's unrelated or we would have heard about millions of truncated files by now. As I mentioned downloads are atomic.

Also he's on macOS.

laurent22 avatar Feb 09 '24 13:02 laurent22

Nothing special. This is my laptop, no special things installed. No proxies, no VPNs, just connected to a normal wifi router, connected to my cable modem.

tydel avatar Feb 09 '24 22:02 tydel

Let me know if there's something else you'd like me to try and I'll be glad to oblige.

tydel avatar Feb 10 '24 21:02 tydel

Sorry I don't know what could be the reason for this issue and I'm assuming it's something outside of Joplin that affected that Dropbox file.

On Joplin side this is simply a corrupted file which has been processed as expected (by not saving it to the database so as to prevent any further corruption). If you have a backup of it somewhere I would suggested you delete it from Dropbox and sync again, then you can restore the PDF file by attaching it to a note in Joplin.

laurent22 avatar Feb 11 '24 11:02 laurent22

Could not replicate unfortunately

laurent22 avatar Apr 15 '24 14:04 laurent22