Couchbase-Ecosystem / cbl-ionic

Ionic Capacitor plugin for Couchbase Lite Enterprise (3.x+)
https://cbl-ionic.dev/
Apache License 2.0
4 stars 1 forks source link

App crashes when collection_GetDocument is called with blob attachment #43

Open brydecena opened 1 month ago

brydecena commented 1 month ago

Describe the bug We migrated an app from 2.x couchbaselite plugin, we are experiencing a crash on the app when 'collection_GetDocument' is called on some areas, after investigating it seems these documents have attachments on it, other 'collection_GetDocument' are returning successfully probably because they don't have an attachment. See image below of XCode logs:

Screenshot 2024-06-16 at 3 00 08 PM

Expected behavior 'collection_GetDocument' should return a response from the plugin

Current behavior App crashes, seems like the crash is happening on this line:

Screenshot 2024-06-16 at 3 06 58 PM

Plugin Version 3.x

Affected Platforms (please complete the following information):

biozal commented 1 month ago

@brydecena

Can you provide me more details like what kind of attachments, how large are they, and what content type are they set to so I can setup something to try and reproduce the issue.

Thanks - Aaron

biozal commented 1 month ago

Using the Example App Get Document page I was able to get back a document with an attachment on it without it crashing, so I'm going to need more details on what your document looks like:

document_with_attachment

biozal commented 1 month ago

Adding to this - here is the Swift behind the scene's break points on this call - here is a breakpoint on the documentAs Map function call:

image

Adding a break point to the code that pulls the blob properties showing it’s properly pulling out the blob properties:

image

Finally the method returning properly:

image

No where can I see this code crashing or breaking with our without blobs.

brydecena commented 1 month ago

Hi @biozal , This is the logs I got from their app using the old plugin they had: Please see files/attachments of this document: { "_attachments":{ "thumbnail-rider.jpg":{ "stub":true, "length":122156, "digest":"sha1-x0DKluwjDwyURWhqzdyV5FdpHzQ=", "revpos":441, "content_type":"image/jpeg" }, "econnectPrestige_2210(TC).pdf":{ "stub":true, "length":3447130, "digest":"sha1-UnXEWfNXCviiBH6rnpBPsVbKyPA=", "revpos":419, "content_type":"application/pdf" }, "premrefund_2401(TC).pdf":{ "stub":true, "length":611964, "digest":"sha1-iNNh0ou2XEYiQ4ll4aDwaxHb34Q=", "revpos":449, "content_type":"application/pdf" }, "VHIS-MC-TC-discount-2207(SC).pdf":{ "stub":true, "length":1563851, "digest":"sha1-LkqLp1rqDCJykIMSeCPW0Lo0ct8=", "revpos":409, "content_type":"application/pdf" }, "brochure-rider-SC.pdf":{ "stub":true, "length":5102666, "digest":"sha1-m5/13VFN+8iM2QO8iH38P3NB4Bc=", "revpos":430, "content_type":"application/pdf" }, "brochure-EN.pdf":{ "stub":true, "length":4989384, "digest":"sha1-PNB/h2tFPxcqIEOraHuhIX9ZMfA=", "revpos":444, "content_type":"application/pdf" }, "econnectPrestige_2210(EN).pdf":{ "stub":true, "length":3688350, "digest":"sha1-l6NfdHQFosfE7QNNHcQ0OqGtp5U=", "revpos":417, "content_type":"application/pdf" }, "brochure-rider-EN.pdf":{ "stub":true, "length":4988404, "digest":"sha1-tfaWi1inXgbksEjyqHI1V7wWQ5M=", "revpos":429, "content_type":"application/pdf" }, "VHIS-MC-TC-discount-2207(EN).pdf":{ "stub":true, "length":1382603, "digest":"sha1-SY8q45adKbd4xI4N4YrGjCxBonE=", "revpos":408, "content_type":"application/pdf" }, "pioneer_flyer-2001(EN).pdf":{ "stub":true, "length":244615, "digest":"sha1-JYWOJaNsxjz1GzbQIPntF89FDB0=", "revpos":399, "content_type":"application/pdf" }, "premrefund_2311(EN).pdf":{ "stub":true, "length":381373, "digest":"sha1-VP1uVmYZwU6unItkaHQXkZYf0aA=", "revpos":438, "content_type":"application/pdf" }, "VHIS-MC-TC-discount-2207(TC).pdf":{ "stub":true, "length":1655996, "digest":"sha1-FRXbaTRS1eas5R3UsAidSIWHG5I=", "revpos":410, "content_type":"application/pdf" }, "rider_flyer2207(SC).pdf":{ "stub":true, "length":1037342, "digest":"sha1-SjI/tEuJBfmbPxwu3SUcV4DXB+I=", "revpos":414, "content_type":"application/pdf" }, "VHIS-MC-TC-discount-2201(SC).pdf":{ "stub":true, "length":1312180, "digest":"sha1-Q66xyTRJMkUs7dz0Em6l869pA/o=", "revpos":385, "content_type":"application/pdf" }, "rider_flyer2207(TC).pdf":{ "stub":true, "length":1016689, "digest":"sha1-nxtFc8XEG1xGdhg+4YFjccU8Vto=", "revpos":415, "content_type":"application/pdf" }, "brochure-TC.pdf":{ "stub":true, "length":5088729, "digest":"sha1-av17bX4ahJDljrSaXVioPoXxey8=", "revpos":446, "content_type":"application/pdf" }, "premrefund_2401(EN).pdf":{ "stub":true, "length":617625, "digest":"sha1-zi20tT0OpYw5Us6WDVpHqG7OWfc=", "revpos":447, "content_type":"application/pdf" }, "thumbnail.jpg":{ "stub":true, "length":121170, "digest":"sha1-f+dGVtUYuCx4yJOqo3Apg6PRbWQ=", "revpos":442, "content_type":"image/jpeg" }, "VHIS-MC-TC-discount-2201(EN).pdf":{ "stub":true, "length":1108994, "digest":"sha1-qRv0jYIv6NzQ8pCf/CjLhKHzV+8=", "revpos":384, "content_type":"application/pdf" }, "premrefund_2311(SC).pdf":{ "stub":true, "length":455135, "digest":"sha1-bAitW76ygr3XK8zxhxeY74+wgCo=", "revpos":439, "content_type":"application/pdf" }, "VHIS-MC-TC-discount-2201(TC).pdf":{ "stub":true, "length":1404299, "digest":"sha1-Rm//Dgh5faKphQ2NTNd/fLBE5ug=", "revpos":386, "content_type":"application/pdf" }, "brochure-rider-TC.pdf":{ "stub":true, "length":5140680, "digest":"sha1-+kBEISFe1nBScnadXP8eJH8NYfY=", "revpos":431, "content_type":"application/pdf" }, "econnectPrestige_2311(SC).pdf":{ "stub":true, "length":1144656, "digest":"sha1-PLkPbRKVGTY4NXJnNUrEfcvyqdY=", "revpos":436, "content_type":"application/pdf" }, "econnectPrestige_2311(TC).pdf":{ "stub":true, "length":1177464, "digest":"sha1-CzncjAZQPMJ5vHYFTZpHJ/Hi9zg=", "revpos":437, "content_type":"application/pdf" }, "brochure-SC.pdf":{ "stub":true, "length":5073145, "digest":"sha1-xmGo/Q7klVCIpTfb2GcKTsHWShM=", "revpos":445, "content_type":"application/pdf" }, "pioneer_flyer-2001(SC).pdf":{ "stub":true, "length":352836, "digest":"sha1-lG57Q+78OvsYS+6W+MQSkZfCNhU=", "revpos":400, "content_type":"application/pdf" }, "pioneer_flyer-2001(TC).pdf":{ "stub":true, "length":365520, "digest":"sha1-y/qzJfxZub91oGkxc4e90DUhMfc=", "revpos":401, "content_type":"application/pdf" }, "premrefund_2311(TC).pdf":{ "stub":true, "length":448879, "digest":"sha1-ntXydREjWfTEBUjFzOQ7hlXiykI=", "revpos":440, "content_type":"application/pdf" }, "rider_flyer2207(EN).pdf":{ "stub":true, "length":1793093, "digest":"sha1-7ZfixAvRjEkrv1v+8U/qG5g498c=", "revpos":413, "content_type":"application/pdf" }, "econnectPrestige_2311(EN).pdf":{ "stub":true, "length":1086779, "digest":"sha1-XEG2UKMsVYQAYxypjli2DxDbKNM=", "revpos":435, "content_type":"application/pdf" }, "premrefund_2401(SC).pdf":{ "stub":true, "length":618282, "digest":"sha1-vvCybMqe/GP459vlxUkOEQvilfA=", "revpos":448, "content_type":"application/pdf" }, "econnectPrestige_2210(SC).pdf":{ "stub":true, "length":3266141, "digest":"sha1-6vSzLQhbl842sbnpig01nI6vqRw=", "revpos":418, "content_type":"application/pdf" } } }

biozal commented 1 month ago

Release 0.1.9 fixes issues with getting blob content and we don't see any issues with pulling documents that have attachments as shown in screen shots.

brydecena commented 1 month ago

Hi @biozal , The crash is happening here when converting the document to dictionary.

Screenshot 2024-06-17 at 9 26 48 PM

Also, please note that the document was obtained from a sync, maybe that made the difference, I believe what you are testing is you created a document and attached the file/blob and then get that document that you created, maybe that's why you have the expected format/value and did not had any error on your testing?

Or probably there is also something on our blob/attachment that was not processed in making a doc or converting it to dictionary.

I try will send you our database/attachment that was created, hope you can test it out. Thanks!