Skip to content

docs: clarify makeMessage is a v1-only helper - #332

Open
cabljac wants to merge 3 commits into
masterfrom
docs/make-message-v1-only
Open

docs: clarify makeMessage is a v1-only helper#332
cabljac wants to merge 3 commits into
masterfrom
docs/make-message-v1-only

Conversation

@cabljac

@cabljac cabljac commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

makeMessage builds a v1 pubsub.Message, but nothing in its docs says so, and passing its result to wrapV2 fails in a confusing way: the v2 mock factory reads the message's json getter, which eagerly runs JSON.parse(base64Decode(data)) and throws on non-JSON payloads before the handler runs (see #235 for the full diagnosis).

This adds jsdoc to both makeMessage overloads marking the helper as v1-only and showing the CloudEvent-partial patterns to use with wrapV2 instead:

wrapV2(fn)({ data: { message: { json: { hello: 'world' } } } });
wrapV2(fn)({ data: { message: { data: base64String } } });

Docs-only change, no runtime behavior affected.

Fixes #235

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the JSDoc documentation for the makeMessage helper functions in src/providers/pubsub.ts. It adds notes clarifying that these helpers are intended exclusively for v1 functions.pubsub.topic(...).onPublish functions and should not be used with wrapV2 for v2 onMessagePublished functions, providing examples of how to handle v2 functions instead. I have no feedback to provide as there are no review comments.

@wandamora wandamora left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for google review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

makeMessage is incompatible with wrapV2

3 participants