Skip to content

Cloud events incorrectly unmarshalled: first argument is undefined, 2nd argument differs from production #41

@comolongo

Description

@comolongo

When Pubsub notifications are sent to a locally hosted cloud event function, the first argument is undefined. It should contain the event information. The 2nd argument though present, does not match production signature; rather than containing metadata about the notification, it contains the entire event object, which should be the contents of argument 1 instead.

My dummy cloud events function:

exports.helloEvents = (data, context) => {
  console.log(data);
  console.log(context);
};

Pub/sub notification being sent:

{
  "subscription": "projects/myproj/subscriptions/mysub",
  "message": {
    "data": "...my base 64 encoded data...",
    "messageId": "1",
    "attributes": {}
  }
}

helloEvents log in production:

Argument 1, data, is:

{  
   "subscription":"projects/myproj/subscriptions/mysub",
   "message":{  
      "data":"...my base 64 encoded data...",
      "messageId":"1",
      "attributes":{}
   }
}

Argument 2, context, is:

{  
   "eventId":"12032d95-089a-4663-9be5-8aafd9d4c623",
   "resource":{  
      "service":"pubsub.googleapis.com",
      "name":"projects/myproj/topics/mytopic"
   },
   "eventType":"google.pubsub.topic.publish",
   "timestamp":"2019-06-16T18:39:44.809Z"
}

On local, the results I get is very different.

  • Argument 1: undefined
  • Argument 2:
{  
   "subscription":"projects/myproj/subscriptions/mysub",
   "message":{  
      "data":"...my base 64 encoded data...",
      "messageId":"1",
      "attributes":{}
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions