FAQ | This is a LIVE service | Changelog

Add new decorator to parse message data via a supplied function

Description

Extend the added pubsub_messages function to add a new decorator which extracts the data in the MessagePublishedData.message.data field from the event, calls a supplied parsing function, and returns the result of this function to the handler.

Further details

This should be an overload of the original decorator, discriminated by an argument which is a callable.

Task list

Acceptance criteria

  • Decorator overload to perform message payload validation/parsing via a function exists
  • Validation or Python ValueError errors raised should be logged, and a 400 returned
  • Other errors have no specific handling, will be caught by functions_framework/flask and a 500 returned (or match existing MR if different)

Links/references

Edited by Mike Knee