Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Firebase Functions v2 - Profobuf compatibility #2086

Open
rfontanarosa opened this issue Nov 12, 2024 · 1 comment
Open

[Feature] Firebase Functions v2 - Profobuf compatibility #2086

rfontanarosa opened this issue Nov 12, 2024 · 1 comment
Labels
type: fr Request for new feature web Angular implementation of Web UI

Comments

@rfontanarosa
Copy link
Collaborator

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

@rfontanarosa rfontanarosa added type: fr Request for new feature web Angular implementation of Web UI labels Nov 12, 2024
@gino-m
Copy link
Collaborator

gino-m commented Nov 14, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: fr Request for new feature web Angular implementation of Web UI
Projects
Status: No status
Development

No branches or pull requests

2 participants