twikoojs / twikoo-cloudflare

9 stars 10 forks source link

Import fail from disqus #6

Closed flashlab closed 2 months ago

flashlab commented 2 months ago

Issue

When I'm trying to import from disqus, job failure along with this error:

D1_TYPE_ERROR: Type 'undefined' not supported for value 'undefined'

Debug

After some debuging, I realize the problem of missing field of imported data. The json before saved is like this:

[{
    "_id": "2145940190",
    "nick": "flashlab",
    "mail": "",
    "link": "",
    "url": "2015/07/04/first-meiya/",
    "href": "http://zzbd.org/2015/07/04/first-meiya/",
    "comment": "<p>测试</p>",
    "ua": "",
    "ip": "",
    "isSpam": false,
    "master": false,
    "created": 1437356069000,
    "updated": 1718347361307
}]

The uid field is missing, which pipe undefined to save function. https://github.com/twikoojs/twikoo-cloudflare/blob/02109cbda66b06f500b1fbd3590461c0d9636854/src/index.js#L783-L793

temporary solution

I'm simply using data.uid ?? '' to bypass the importing process, but was it a good idea to leave uid empty?

Tao-VanJS commented 2 months ago

Yes. I think https://github.com/twikoojs/twikoo-cloudflare/commit/35f44064703da56128c19fe7c99d5da23e0713e0 fixed the issue.

uid is a cookie-based anonymous ID to test if existing comments were posted by you. If you import comments from other sources, there is no way to know if the comments were actually posted by you. Thus there is no harm to leave it empty.