etesync / etesync-web

An EteSync web client
https://www.etesync.com
GNU Affero General Public License v3.0
245 stars 29 forks source link

import fails with generic error - seems to be caused by uncaught exception in dialog #224

Open jzacsh opened 3 years ago

jzacsh commented 3 years ago

here's a copy/pasted stacktrace from my js console:

stacktrace from TypeError in `ImportDialog.tsx:85` ``` ImportDialog.tsx:85 TypeError: Cannot read property 'parent' of null at e.addSubcomponent (ical.js:2610) at Object.updateTimezones (ical.js:94) at n.value (pim-types.ts:136) at ImportDialog.tsx:72 at c (runtime.js:63) at Generator._invoke (runtime.js:293) at Generator.next (runtime.js:118) at r (asyncToGenerator.js:3) at A (asyncToGenerator.js:25) at asyncToGenerator.js:32 (anonymous) @ ImportDialog.tsx:85 c @ runtime.js:63 (anonymous) @ runtime.js:293 (anonymous) @ runtime.js:118 r @ asyncToGenerator.js:3 A @ asyncToGenerator.js:25 (anonymous) @ asyncToGenerator.js:32 (anonymous) @ asyncToGenerator.js:21 load (async) S @ ImportDialog.tsx:56 d @ ImportDialog.tsx:133 (anonymous) @ index.js:620 Promise.then (async) (anonymous) @ index.js:594 (anonymous) @ index.js:102 (anonymous) @ index.js:100 A @ react-dom.production.min.js:14 h @ react-dom.production.min.js:14 (anonymous) @ react-dom.production.min.js:14 I @ react-dom.production.min.js:15 at @ react-dom.production.min.js:52 it @ react-dom.production.min.js:51 At @ react-dom.production.min.js:52 ht @ react-dom.production.min.js:56 N @ react-dom.production.min.js:287 H @ react-dom.production.min.js:19 Zt @ react-dom.production.min.js:70 Xt @ react-dom.production.min.js:69 t.unstable_runWithPriority @ scheduler.production.min.js:19 Ui @ react-dom.production.min.js:122 R @ react-dom.production.min.js:287 Vt @ react-dom.production.min.js:68 ```
stacktrace from TypeError in `ical.js:2610` and here's another - this one came a moment _later_ after my screenshot - I think: ``` ical.js:2610 Uncaught (in promise) TypeError: Cannot read property 'parent' of null at e.addSubcomponent (ical.js:2610) at Object.updateTimezones (ical.js:94) at n.value (pim-types.ts:136) at ImportDialog.tsx:72 at c (runtime.js:63) at Generator._invoke (runtime.js:293) at Generator.next (runtime.js:118) at r (asyncToGenerator.js:3) at A (asyncToGenerator.js:25) at asyncToGenerator.js:32 addSubcomponent @ ical.js:2610 updateTimezones @ ical.js:94 value @ pim-types.ts:136 (anonymous) @ ImportDialog.tsx:72 c @ runtime.js:63 (anonymous) @ runtime.js:293 (anonymous) @ runtime.js:118 r @ asyncToGenerator.js:3 A @ asyncToGenerator.js:25 (anonymous) @ asyncToGenerator.js:32 (anonymous) @ asyncToGenerator.js:21 load (async) S @ ImportDialog.tsx:56 d @ ImportDialog.tsx:133 (anonymous) @ index.js:620 Promise.then (async) (anonymous) @ index.js:594 (anonymous) @ index.js:102 (anonymous) @ index.js:100 A @ react-dom.production.min.js:14 h @ react-dom.production.min.js:14 (anonymous) @ react-dom.production.min.js:14 I @ react-dom.production.min.js:15 at @ react-dom.production.min.js:52 it @ react-dom.production.min.js:51 At @ react-dom.production.min.js:52 ht @ react-dom.production.min.js:56 N @ react-dom.production.min.js:287 H @ react-dom.production.min.js:19 Zt @ react-dom.production.min.js:70 Xt @ react-dom.production.min.js:69 t.unstable_runWithPriority @ scheduler.production.min.js:19 Ui @ react-dom.production.min.js:122 R @ react-dom.production.min.js:287 Vt @ react-dom.production.min.js:68 ```

here's what I saw when clicking a file-select dialog, and selecting an ics file:

Screenshot from 2021-08-31 13-42-14

data to reproduce

To reproduce this I've modified my ICS file via texteditor (just to remove my personal information), and I think it's still a valid event (yet still hits the same error). Here's the content of the ics:

BEGIN:VCALENDAR
PRODID://Etesync Bugreport//Etesync Sample Data//
VERSION:2.0
METHOD:PUBLISH
CALSCALE:GREGORIAN
BEGIN:VEVENT
UID:3FYSUR
DTSTAMP;TZID=UTC:20210830T132943
DTSTART;TZID=UTC:20210918T222500
DTEND;TZID=UTC:20210920T012500
DESCRIPTION:this is copy written just for an etesync bugreport
LOCATION:github issue report
SUMMARY:Etesync Sample Event Confirmation
TRANSP:OPAQUE
X-MICROSOFT-CDO-BUSYSTATUS:FREE
X-MICROSOFT-CDO-ALLDAYEVENT:TRUE
BEGIN:VALARM
TRIGGER;VALUE=DURATION:-P1D
ACTION:DISPLAY
DESCRIPTION:It's time to debug an etesync issue
END:VALARM
END:VEVENT
END:VCALENDAR
jzacsh commented 2 years ago

looking at the stack trace I reported above in August, and looking at that upstream code, I think this is a totally different stack trace.

Either way, here's another uncaught exception I'm able to reproduce (with the fix)...

BEGIN:VCARD
VERSION:4.0
ITEM1.EMAIL;PREF=1:vcard@testuser.com
END:VCARD

(drag and drop that^ as a file into the dialog and you'll get the stack trace reported in the below issue)


(pasting from https://github.com/etesync/server/issues/111#issuecomment-984286231 comment)

side-note: I found a parsing bug here where etesync's wrapper doesn't check the contents it gets back from ICAL.parse call before using it. Then the uid getter() fails on line 212 of getFirstProperty because this.jCal is actually a zero-length array

The fix should be:

   function onFileDropContact(acceptedFiles: File[], rejectedFiles: File[]) {
     const itemsCreator = (fileText: string) => {
       const mainComp = ICAL.parse(fileText);
-      return mainComp.map((comp) => {
+      return mainComp.filter(c => c.length).map((comp) => {
         const ret = new ContactType(new ICAL.Component(comp));
         if (!ret.uid) {
           ret.uid = uuid.v4();
         }
         return ret;
       });
     };

     onFileDropCommon(itemsCreator, acceptedFiles, rejectedFiles);
   }