Skip to content

Handle stringified webhook metadata payloads#3642

Merged
steven-tey merged 2 commits into
mainfrom
fix-webhook-metadata
Mar 24, 2026
Merged

Handle stringified webhook metadata payloads#3642
steven-tey merged 2 commits into
mainfrom
fix-webhook-metadata

Conversation

@devkiran
Copy link
Copy Markdown
Collaborator

@devkiran devkiran commented Mar 24, 2026

Summary by CodeRabbit

  • Improvements
    • Refined webhook metadata handling for lead and sale events. Metadata fields now intelligently process incoming data with automatic JSON parsing for string-formatted values and improved fallback handling. This provides better support for various data formats while maintaining complete backward compatibility with existing webhook integrations.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview Mar 24, 2026 11:49am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 662245c0-75e5-4a32-9858-41db5287803d

📥 Commits

Reviewing files that changed from the base of the PR and between b3125b9 and 3f3cf2a.

📒 Files selected for processing (1)
  • apps/web/lib/webhook/schemas.ts

📝 Walkthrough

Walkthrough

Modified webhook schemas to preprocess metadata fields by attempting to parse JSON strings, with fallback to the original value. Added coerceJsonString utility and updated both leadWebhookEventSchema and saleWebhookEventSchema to use a new metadataSchema instead of direct nullable record definitions.

Changes

Cohort / File(s) Summary
Webhook Schema Enhancement
apps/web/lib/webhook/schemas.ts
Added coerceJsonString utility function and metadataSchema with preprocessing to parse JSON strings; applied to metadata fields in both leadWebhookEventSchema and saleWebhookEventSchema, replacing direct nullable record declarations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A schema so clever, I hop with delight,
JSON strings now parsed, metadata shines bright!
Coerce and preprocess, fallback with care,
Webhooks now handle the data with flair! 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Handle stringified webhook metadata payloads' directly describes the main change: handling metadata values that arrive as stringified JSON by adding preprocessing with JSON.parse.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-webhook-metadata

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@steven-tey steven-tey merged commit 5668088 into main Mar 24, 2026
12 of 13 checks passed
@steven-tey steven-tey deleted the fix-webhook-metadata branch March 24, 2026 18:06
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.

2 participants