Error: Argument "data" is not a valid Document
See original GitHub issueExpected behavior
Commandline export and programmatic import does not cause an error.
Actual behavior
It does cause an error.
Steps to reproduce the behavior
-
Make sure there is a Timestamp in the database.
-
run
firestore-export --accountCredentials path/to/credentials/file.json --backupFile /backups/myDatabase.json
-
programmatically import by the example in the readme.md:
const {firestoreImport} = require('node-firestore-import-export');
const FirestoreData = require("./backups/myDatabase.json");
const admin = require('firestore-admin');
let serviceAccount = require('service-account.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "db-url"
});
firestore = admin.firestore();
const settings = {timestampsInSnapshots: true};
firestore.settings(settings);
firestoreImport(FirestoreData, firestore);
- Error is thrown as follows:
(node:8088) UnhandledPromiseRejectionWarning: Error: Argument "data" is not a valid Document. Detected an object of type "Timestamp" that doesn't match the expected instance. Please ensure that the Firestore types you are using are from the same NPM package.
at Validator.(anonymous function).values [as isDocument] (C:\Users\me\projects\maklr-backend\tools\node_modules\@google-cloud\firestore\build\src\validate.js:99:27)
at WriteBatch.set (C:\Users\me\projects\maklr-backend\tools\node_modules\@google-cloud\firestore\build\src\write-batch.js:232:25)
at C:\Users\me\projects\maklr-backend\tools\node_modules\node-firestore-import-export\dist\lib\import.js:68:19
at Array.map (<anonymous>)
at C:\Users\me\projects\maklr-backend\tools\node_modules\node-firestore-import-export\dist\lib\import.js:57:22
at Array.map (<anonymous>)
at setDocuments (C:\Users\me\projects\maklr-backend\tools\node_modules\node-firestore-import-export\dist\lib\import.js:55:32)
at importData (C:\Users\me\projects\maklr-backend\tools\node_modules\node-firestore-import-export\dist\lib\import.js:28:43)
at importAuthUsers.then (C:\Users\me\projects\maklr-backend\tools\restoreEnvironment.js:85:20)
at <anonymous>
(node:8088) 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:8088) [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.
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.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
node.js - Error: Argument "data" is not a valid Document. Input ...
Error : Argument "data" is not a valid Document. Input is not a plain JavaScript object. when updating a document, using firebase admin...
Read more >Value for argument "data" is not a valid Firestore document ...
Error : Value for argument "data" is not a valid Firestore document. Detected an object of type "DocumentReference" that doesn't match the expected...
Read more >Firestore error: Error: Value for argument "data" is not a valid ...
But it was occured error like below. Error: Value for argument "data" is not a valid Firestore document. Input is not a plain...
Read more >R Error in FUN : invalid 'type' (character) of argument
The previous output of the RStudio console shows that our example data is a vector consisting of five elements. Example 1: Reproduce the...
Read more >Argument "data" is not a valid Document. Input is not a plain ...
I had same problem, in my case I'd forgot to add Content-Type:application/json to my header when sending request, and then the object was...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just put this structure data and it worked.
+1, came across the same issue when trying to import anything with timestamps: