Skip to content

fix: preserve metadata key casing in multipart form-data requests#729

Merged
tasdrake merged 1 commit intomainfrom
CUST-5361-webhook-keys-not-standardized
May 7, 2026
Merged

fix: preserve metadata key casing in multipart form-data requests#729
tasdrake merged 1 commit intomainfrom
CUST-5361-webhook-keys-not-standardized

Conversation

@tasdrake
Copy link
Copy Markdown
Contributor

@tasdrake tasdrake commented May 7, 2026

When sending messages with a total payload >= 3MB, the SDK switches from JSON to multipart/form-data serialization. The form-data path in _buildFormRequest() was calling objKeysToSnakeCase() without excluding the metadata field, causing metadata keys like myCustomKey to be silently converted to my_custom_key. The JSON path in apiClient.ts already correctly excluded metadata from case conversion.

This fix adds the ['metadata'] exclusion to both _buildFormRequest() and calculateTotalPayloadSize(), making metadata handling consistent across all serialization paths (messages, drafts create/update).

Includes a regression test that verifies camelCase metadata keys survive the multipart serialization path unchanged.

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

The form-data serialization path (used when payload >= 3MB) was
converting metadata keys to snake_case, unlike the JSON body path
which correctly excluded them. This caused metadata key casing to
change silently when sending messages with large attachments.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.72%. Comparing base (ca893af) to head (cd08e04).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #729   +/-   ##
=======================================
  Coverage   98.72%   98.72%           
=======================================
  Files          39       39           
  Lines         860      860           
  Branches       69       69           
=======================================
  Hits          849      849           
  Misses         11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tasdrake tasdrake marked this pull request as ready for review May 7, 2026 18:17
@tasdrake tasdrake merged commit a469fa0 into main May 7, 2026
10 checks passed
@tasdrake tasdrake mentioned this pull request May 8, 2026
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