Repository navigation
fix: keep custom data keys as written at any depth - #271
Draft
jedpattersonpaddle wants to merge 6 commits into
Draft
jedpattersonpaddle wants to merge 6 commits into
jedpattersonpaddle wants to merge 6 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
customDatawas a top-level key of the request body. Anywhere deeper, it rewrote the keys. A caller who senttenantIdhadtenant_idstored, and a webhook handler that looked fortenantIdfound nothing.What changed
customDataandcustom_dataspellings. This fixes simulation payloads insimulations.createandsimulations.update.tenantIdcame back astenantid. This coverswebhooks.unmarshal,events.list,notifications.get,notifications.listand unknown actions insubscriptions.listHistory.For the reviewer
fetch.## Unreleasedand this PR does not bump the version. Should it ship as a patch or a minor? That needs a maintainer's call.fix: keep custom data keys on unknown webhook events. [Bug]:convertToSnakeCaserecursively converts keys insidecustom_dataon simulation payloads #220 does not need it, so it can move to a separate PR if you prefer.fetch, and 12 of the new ones fail without the two source changes.Skills used
superpowers:dispatching-parallel-agentsworkflow-authoringpaddle-shared:open-prpaddle-shared:pr-readability