-
Notifications
You must be signed in to change notification settings - Fork 167
Event parsing doesn't match Cloud Functions in background mode #96
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
Comments
I'm not sure the expected behavior in this case to be honest. |
The Functions Framework supports multiple event formats:
If you want to trigger your function with CloudEvents, which may be useful for integrations beyond Cloud Functions, use the CloudEvents format. But if you want to trigger the function like a background function in Cloud Functions service, use one of the other formats mentioned above. We should clarify this in the Functions Framework docs. |
@swalkowski, I posted a comment on this issue too explaining the behavior I am seeing, but it seems related to this issue as well. What I am trying to accomplish is a local dev environment where:
Expected behvior: the function is executed with arguments similar to those it receives while running in GCF. Actual behavrior: the function is executed with the first argument being
Is this a problem with the emulator not sending the same message format as production PubSub does? Or is it a problem with how |
@burtonjc Did you find any solutions for this issue? Pains us as well trying to setup a local devenv for cloud functions. |
Here's a sample integration test using the We have lots of other samples for GCF too in that repo. |
Hey there!
Related to #41 and #85, I ran into a lot of confusion trying to sort out what the format should be for the request body to a local background function.
In production a background function has the following for the first parameter:
and the following for the "context" parameter:
The current docs for using the functions framework for events suggests
curl
ing data in a format that results in the parameters not matching the above - the first parameter becomes:And the "context" parameter:
Digging into the source code,
functions-framework-nodejs/src/invoker.ts
Lines 431 to 447 in de6ef38
(Further evidence this is expected is in this WIP branch for NodeJS samples.)
Using the above POST body seems to result in function parameters that most closely match production, and although it doesn't match the POST body for push messages I'm assuming that's what users should send if they want their function to act closest to what they will see when they deploy to Cloud Functions.
Is this correct?
The text was updated successfully, but these errors were encountered: