Skip to content

fix: keep custom data keys as written at any depth - #271

Draft
jedpattersonpaddle wants to merge 6 commits into
mainfrom
fix_custom_data_nested_snake_case
Draft

jedpattersonpaddle wants to merge 6 commits into
mainfrom
fix_custom_data_nested_snake_case

Conversation

@jedpattersonpaddle

Copy link
Copy Markdown
Member

Fixes #220. Builds on #226.

Why

Keys inside custom data should reach Paddle exactly as the caller wrote them. The SDK only did that when customData was a top-level key of the request body. Anywhere deeper, it rewrote the keys. A caller who sent tenantId had tenant_id stored, and a webhook handler that looked for tenantId found nothing.

What changed

  • Requests keep custom data keys as written at any depth, for both the customData and custom_data spellings. This fixes simulation payloads in simulations.create and simulations.update.
  • The same fix covers custom data on non-catalog prices, products and discounts inside transaction and subscription requests.
  • Responses no longer rewrite custom data keys for event types the SDK does not know. Before, tenantId came back as tenantid. This covers webhooks.unmarshal, events.list, notifications.get, notifications.list and unknown actions in subscriptions.listHistory.

For the reviewer

  • The first commit is the one from fix(case-helpers): preserve custom_data keys at any nesting depth #226, cherry-picked with its author kept. The later commits fix the lint error that blocked that PR and trim its tests. They also add tests that check the body passed to fetch.
  • This changes what is stored for callers who already send nested custom data. Until now their keys were stored in snake case. New writes keep the keys as sent, so old and new records can differ. The changelog entry says this.
  • The entry sits under ## Unreleased and this PR does not bump the version. Should it ship as a patch or a minor? That needs a maintainer's call.
  • The response fix is its own commit, fix: keep custom data keys on unknown webhook events. [Bug]: convertToSnakeCase recursively converts keys inside custom_data on simulation payloads #220 does not need it, so it can move to a separate PR if you prefer.
  • Not tested against the live API. The tests mock fetch, and 12 of the new ones fail without the two source changes.
Skills used
  • superpowers:dispatching-parallel-agents
  • workflow-authoring
  • paddle-shared:open-pr
  • paddle-shared:pr-readability

TabishRiazBajwa and others added 6 commits November 20, 2026 10:24
convertToSnakeCase only guarded customData at the top level of the request body. Simulation payloads nest customData inside payload.data,
so its keys were silently snake_cased before being sent to the API,
breaking webhook handlers that expected the original camelCase keys.

Make the customData carve-out depth-insensitive by checking for the key
recursively during decamelization, not just at the top level.

Fixes #220
Add the .js extension eslint requires on the test import, drop unit cases that
repeat each other or are covered by the request-level tests, and replace the
comments that restate the code with the reason custom data is left alone.
Send simulation, transaction and subscription requests through Client so the
body that reaches fetch is asserted, for both the customData and custom_data
spellings. Also pin that responses and known webhook events already keep nested
custom data keys.
Events the SDK has no entity for fall back to GenericEvent, which camelCased
every key including those inside custom_data, and lowercased keys that were
already camelCase (tenantId became tenantid). Leave custom_data values alone,
matching what the typed entities already do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: convertToSnakeCase recursively converts keys inside custom_data on simulation payloads

2 participants