Skip to content

[Feature] Firebase Functions v2 - Profobuf compatibility #2086

@rfontanarosa

Description

@rfontanarosa

Trying to implement a v2 firebase trigger function, it returns this error:

Error: Failed to decode protobuf and create a snapshot.
    at entryFromArgs (/workspace/node_modules/firebase-functions/lib/logger/index.js:133:19)
    at Object.error (/workspace/node_modules/firebase-functions/lib/logger/index.js:120:11)
    at createSnapshotFromProtobuf (/workspace/node_modules/firebase-functions/lib/common/providers/firestore.js:61:16)
    at createSnapshot (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:172:59)
    at makeFirestoreEvent (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:209:15)
    at func (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:300:32)
    at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:119:25
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

generated by this:

function createSnapshot(event) {
    var _a, _b, _c, _d;
    if (((_a = event.datacontenttype) === null || _a === void 0 ? void 0 : _a.includes("application/protobuf")) || Buffer.isBuffer(event.data)) {
        return (0, firestore_1.createSnapshotFromProtobuf)(event.data, getPath(event), event.database);
    }
    else if ((_b = event.datacontenttype) === null || _b === void 0 ? void 0 : _b.includes("application/json")) {
        return (0, firestore_1.createSnapshotFromJson)(event.data, event.source, (_c = event.data.value) === null || _c === void 0 ? void 0 : _c.createTime, (_d = event.data.value) === null || _d === void 0 ? void 0 : _d.updateTime, event.database);
    }
    else {
        logger.error(`Cannot determine payload type, datacontenttype is ${event.datacontenttype}, failing out.`);
        throw Error("Error: Cannot parse event payload.");
    }
}

@gino-m fyi

Metadata

Metadata

Assignees

Labels

type: frRequest for new featurewebAngular implementation of Web UI
No fields configured for Feature.

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions