Google Cloud Feature Error: "Unable to decode type from Firestore value"

Using the Firestore application in a React application, I test with Google's cloud functions to capture a document field, and then create a new field in Firestore using this field. The other day I worked, and now it is not.

This is the error I get in the Google Cloud Function Log:

Error: Cannot decode type from Firestore value: {"stringValue": "sox"} in DocumentSnapshot._decodeValue

Below is the code I used. It is very similar to the code here: https://firebase.google.com/docs/firestore/extend-with-functions#writing_data

exports.createShowDoubleName = functions.firestore
  .document('shows/{showId}')
  .onUpdate((event) => {
    const data = event.data.data();
    const previousData = event.data.previous.data();
    if (data.name == previousData.name) return;
    var name = data.name;
    var newname = name+"_"+name
     return event.data.ref.set({
        newname: newname
      }, {merge: true});
});
+4
source share
4

firebase-functions SDK 0.7.5 . firebase-admin 5.5.0. :

npm install firebase-functions@0.7.5
+1

(0.7.4) firebase-functions.

, firebase-functions . :

if (data.name == previousData.name) return;

:

if (data.name == previousData.name) return null;

firebase-functions, functions :

npm install firebase-functions@latest --save
+2

I had the same problem and the same error. After updating the firebase and firebase-admin functions (npm install firebase-functions @latest -save) and (npm install firebase-admin @latest -save), he solved the problem. Turning to the logs, the problem seems to be in the old version of firebase-admin. Now I am running the administrative version 5.5.1 and the functions of version 0.7.4.

+1
source

Definitely just need to update something.

Open a terminal , go to the function folder and run this update:

npm install firebase-functions@latest firebase-admin@latest --save

+1
source

Source: https://habr.com/ru/post/1690999/


All Articles