Open ErwinAI opened 5 years ago
One addition, I managed to trace it back to two specific documents that both have three fields, all built like:
"projectStart": {
"__datatype__": "timestamp",
"value": {
"_seconds": 1549076400,
"_nanoseconds": 0
}
}
Using the firestore instance normally used for a web application (so not the firestore instance from the admin package) crashes at the same action it seems, but the error is a bit more revealing. It seems the custom object is not converted properly?
(node:10804) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
(node:10804) UnhandledPromiseRejectionWarning: FirebaseError: Function WriteBatch.set() called with invalid data. Unsupported field value: a custom object (found in field dateCreated)
at new FirestoreError (C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:353:28)
at ParseContext.createError (C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:19022:16)
at validatePlainObject (C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:19402:27)
at UserDataConverter.parseData (C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:19208:13)
at C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:19251:41
at forEach (C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:455:13)
at UserDataConverter.parseObject (C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:19250:13)
at UserDataConverter.parseData (C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:19209:25)
at UserDataConverter.parseMergeData (C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:19082:31)
at WriteBatch.set (C:\Users\me\projects\maklr-backend\tools\node_modules\@firebase\firestore\dist\index.node.cjs.js:19834:46)
(node:10804) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10804) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Do you run into the same errors when trying to import and export from the command line?
+1
I am running into the same issue as well
Update: Im trying to import using a cloud function.
@jloosli any help is greatly appreciated
same here
@tafm I ended up using this script, it worked great for me: https://gist.github.com/sturmenta/cbbe898227cb1eaca7f85d0191eaec7e
+1, came across the same issue when trying to import anything with timestamps:
"activatedAt": {
"__datatype__": "timestamp",
"value": {
"_seconds": 1609184426,
"_nanoseconds": 734000000
}
},
I just put this structure data and it worked.
{
"test": {
"first-key": {
"website": "dalenguyen.me",
"date": {
"_seconds": 1534046400,
"_nanoseconds": 0
},
"schedule": {
"time": {
"_seconds": 1534046400,
"_nanoseconds": 0
}
},
"three": {
"level": {
"time": {
"_seconds": 1534046400,
"_nanoseconds": 0
}
}
},
"custom": {
"lastName": "Nguyen",
"firstName": "Dale"
},
"location": {
"_latitude": 49.290683,
"_longitude": -123.133956
},
"locationNested": {
"geopoint": {
"_latitude": 49.290683,
"_longitude": -123.133956
}
},
"locations": [
{
"_latitude": 50.290683,
"_longitude": -123.133956
},
{
"_latitude": 51.290683,
"_longitude": -123.133956
}
],
"email": "dungnq@itbox4vn.com",
"secondRef": "test/second-key",
"arrayRef": ["test/second-key", "test/second-key"],
"nestedRef": {
"secondRef": "test/second-key"
},
"subCollection": {
"test/first-key/details": {
"33J2A10u5902CXagoBP6": {
"dogId": "2",
"dogName": "hello"
},
"MSZTWEP7Lewx0Qr1Mu5s": {
"dogName": "lala",
"dogId": "2"
}
},
"test/first-key/contacts": {
"33J2A10u5902CXagoBP6": {
"contactId": "1",
"name": "Dale Nguyen"
},
"MSZTWEP7Lewx0Qr1Mu5s": {
"contactId": "2",
"name": "Yen Nguyen"
}
}
}
},
"second-key": {
"website": "google.com",
"date": {
"_seconds": 1534262435,
"_nanoseconds": 0
},
"custom": {
"lastName": "Potter",
"firstName": "Harry"
},
"location": {
"_latitude": 49.290683,
"_longitude": -123.133956
},
"email": "test@dalenguyen.me"
}
}
}
Expected behavior
Commandline export and programmatic import does not cause an error.
Actual behavior
It does cause an error.
Steps to reproduce the behavior
1) Make sure there is a Timestamp in the database. 2) run
firestore-export --accountCredentials path/to/credentials/file.json --backupFile /backups/myDatabase.json
3) programmatically import by the example in the readme.md:
4) Error is thrown as follows:
I've seen issue #36 , which seems to be similar to my difficulties. However, the issue mentions that the issue is fixed. I am using the most recent version (0.13.2) so I presume it's either not entirely fixed, or it's the same error but with a different cause.