-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Cloud Functions background sample appears incorrect: entity.data.myMessage #260
Comments
Which property do you mean?
|
I just tested it, seems to work fine. The error case:
Then looking at https://console.cloud.google.com/logs/viewer?project=nodejs-docs-samples&resource=cloud_function I see: The success case:
|
I agree though, it's not clear what the use case is for that particular sample. |
But, you're cheating :-) The code is an example of a Cloud Function being used as a background function. There are two ways background functions should be triggered, in response to a: -- Pub/Sub topic being published In both of those cases, the event.data schema is defined by the originating service. For Pub/Sub,
I receive a string encoding of the JSON object (not a JSON object):
For Cloud Storage,
I receive:
If I deploy your function as-is, I receive an error:
|
You are right, this particular sample only works if you call it with |
I removed this sample from the docs. |
#260) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <[email protected]> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
nodejs-docs-samples/functions/background/index.js line 27
commit: f7b29b3
introduces 'event.data.myMessage'
IIUC 'event' object does not contain this property and the code does not work:
https://cloud.google.com/functions/docs/writing/background#event_parameter
A different and probably better mechanism is used here:
https://cloud.google.com/functions/docs/tutorials/pubsub#preparing_the_application
The text was updated successfully, but these errors were encountered: