Skip to content

test: reproduce Hono and Next.js webhook reply double encoding - #955

Draft
KnightNiwrem wants to merge 1 commit into
grammyjs:v2from
KnightNiwrem:test/webhook-reply-double-json
Draft

KnightNiwrem wants to merge 1 commit into
grammyjs:v2from
KnightNiwrem:test/webhook-reply-double-json

Conversation

@KnightNiwrem

@KnightNiwrem KnightNiwrem commented Aug 16, 2026

Copy link
Copy Markdown
Member

Note

This PR was primarily written by GPT-5.6 Sol xhigh in ChatGPT Work.

Summary

This test-only draft PR adds three CI cases for webhook reply serialization:

  1. stdHttp passes the serialized Bot API request through unchanged.
  2. Hono is exercised through a real Hono application.
  3. Next.js is exercised with a response double that implements the public .json(value) serialization contract.

All three cases use the same shared grammY webhook reply path and the same payload:

{"method":"sendMessage","chat_id":1,"text":"hello"}

What this demonstrates

The passing stdHttp control rules out the shared webhook reply envelope as the source of the corruption: it receives and returns the expected serialized JSON unchanged.

The Hono and Next.js cases then fail in their adapter-specific response paths. Both produce a JSON string literal instead of a Bot API request object:

"{\"method\":\"sendMessage\",\"chat_id\":1,\"text\":\"hello\"}"

The Hono case uses the framework itself. The Next.js response double applies JSON.stringify(value), matching the behavior of NextApiResponse.json.

Current CI result

The Ubuntu test job records the intended result:

stdHttp should preserve serialized webhook replies ... ok
Hono should preserve serialized webhook replies ... FAILED
Next.js should preserve serialized webhook replies ... FAILED

Both failures show the extra outer quotes and escaped inner JSON. The rest of the webhook-reply tests continue to pass.

The separate CI job confirms that formatting, linting, type-checking, and the publish dry-run all pass.

Purpose

This PR intentionally contains no production fix. It is a minimal reproducer and should not be merged in its current failing state.

@KnorpelSenf KnorpelSenf added the v2 related to grammY 2.0 label Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 related to grammY 2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants