Skip to content

fix(webhooks): skip unrecognized Instagram/Messenger webhook events instead of throwing - #832

Merged
sung17 merged 1 commit into
ChatbotXIO:mainfrom
AlanSyue:fix/webhook-parse-resilience
Jul 27, 2026
Merged

sung17 merged 1 commit into
ChatbotXIO:mainfrom
AlanSyue:fix/webhook-parse-resilience

Conversation

@AlanSyue

Copy link
Copy Markdown
Contributor

What

The Instagram and Messenger webhook handlers parse the top-level webhook envelope with schema.parse(...), which throws when Meta delivers an event shape the schema doesn't cover (e.g. some Instagram messaging events without sender/recipient). A single unrecognized event then fails the whole webhook request — filling logs with Failed to process webhook event errors and causing Meta to retry.

Changes

  • Instagram (integrations/instagram/src/handlers/webhook.ts) and Messenger (integrations/messenger/src/handlers/webhook.ts): parse the top-level webhook with safeParse instead of parse. On failure, log a concise warning (issue code/path only) and skip the event instead of throwing.
  • Mirrors the pattern already used for comment-value parsing in the same handlers.
  • Trims full payloads from webhook exception/log messages — issue codes/paths are enough to debug, and raw payloads can contain user data.

Why

Webhook endpoints should tolerate unrecognized / new event types; Meta regularly sends fields and event kinds beyond any fixed schema. Skipping what we don't handle keeps the endpoint healthy and avoids unnecessary retries and noisy error logs, without affecting the events we do process (messages, comments).

Verification

  • check-types (integration-instagram, integration-messenger) and unit tests pass.

@sung17
sung17 merged commit f1ef58c into ChatbotXIO:main Jul 27, 2026
@realcodesiman realcodesiman added the bug Something isn't working as expected label Jul 31, 2026
viethung0o0 pushed a commit that referenced this pull request Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants