TMink / Digitales-3D-Feldbuch

Mozilla Public License 2.0
2 stars 0 forks source link

_id is undefined when importing a fieldbookBackup #219

Closed JuHardtung closed 9 months ago

JuHardtung commented 9 months ago

When you export a fieldbookBackup, all the data in it is correct. The image below shows the contents of the exported data file with the correct _ids:

image

But then when you try to import this data, only the _ids of the imported activities become undefined.

I have no clue why this only happens for activities. The relevant code is in DataBackup.vue https://github.com/TMink/Digitales-3D-Feldbuch-Projekt-3-/blob/2a7812b5481f2b41a42c722c1318a8539b76239d/src/frontend/src/components/DataBackup.vue#L280-L285

The information in fileData is still correct, but after JSON.parse(fileData) the variable dbData already contains the missing _id in the activity (as seen in the image below)

chrome_ucUdC54nV2

As I said, I have no clue why JSON.parse() fails only in this particular case. I've been debugging and trying to find the issue for way too long now, so any help would be highly appreciated!

JuHardtung commented 9 months ago

It makes absolutely no sense whatsoever, but a5f30b07a07ab1bd20973c4a8131869fee776704 fixes the issue.

Apparently, an earlier change to fix imports of older backups with different parameter naming schemes was somehow also applied to new backups. But it doesn't make sense that this caused the issue, because as explained with the above pictures, the error happened exactly when the backup file was parsed with JSON.parse(). Exactly one line before that all the data is correct and after this line it was wrong.

The fix for legacy dataBackups is happening at a waaaay later point, so I have no clue why this caused the issue at this specific point. Maybe some asynchronous shenanigans or some solar flares that caused bitflips or whatever.

Well, at the end it doesn't matter, but it is fixed now... Rant over!