fix/deep-symbolize-keys-arrays - #7
Merged
Merged
Conversation
…s even after we thought we'd converted them to the symbol-keyed format the rest of the gem uses consistently. The root cause was a gap in our key-symbolizing helper: it only converted keys one level deep into arrays, so any list of records nested inside a response (like a form schema's list of fields) stayed on the old string-key format. This already caused a real bug for a downstream team, whose code assumed symbol-key access, quietly got back a nil lookup, and fell through to the wrong logic path without an error. This PR fixes the underlying helper and brings eight response methods that had been overlooked into line with the rest of the gem, so every response is now consistently symbol-keyed. Because some calling code out there may currently rely on the old string-key behavior, this is a breaking change and the gem version is bumped accordingly. This PR is ready for review but shouldn't be merged yet, since the downstream team needs a coordinated follow-up change on their end first. - Fixed the shared `Util.deep_symbolize_keys` helper so it recurses into arrays and not just nested hashes, matching how Rails' own `deep_transform_keys` behaves, so a list of records nested inside a response (for example a form schema's `fields` list) now gets converted consistently. - Updated `Beneficiary.validate`, `.verify_account`, `.api_schema`, `.form_schema`, and `.supported_financial_institutions` to run their responses through that helper before returning them, so callers get the same consistent access as every other Beneficiary method. - Made the same fix to `ConnectedAccount.wallet_info`, `BillingCustomer#bank_transfer_instructions`, and `GlobalAccount#generate_statement_letter`, closing out the remaining spots where a response was being handed back unconverted. - Bumped the gem to 0.8.0 and documented this as a breaking change in the changelog, since any code reading these responses with string keys will need to switch to symbol keys. - Updated and added tests across the util and affected resource specs to check symbol-key access, including inside nested lists, and corrected a batch transfer test that had unknowingly been depending on the old, buggy behavior. - Left `Error#details`/`#param` as-is for now, since a downstream consumer currently reads those with string keys. Changing that needs its own coordinated update on their side, so it's flagged as a follow-up rather than bundled into this change.
…_get; also symbolize Error#details
adrian-y1
approved these changes
Sep 2, 2026
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.
Summary
Some Airwallex API responses were silently kept as string-keyed hashes even after we thought we'd converted them to the symbol-keyed format the rest of the gem uses consistently.
The root cause was a gap in our key-symbolizing helper: it only converted keys one level deep into arrays, so any list of records nested inside a response (like a form schema's list of fields, or an error's field-level detail list) stayed on the old string-key format.
This already caused a real bug for a downstream team, whose code assumed symbol-key access, quietly got back a nil lookup, and fell through to the wrong logic path without an error.
This PR fixes the underlying helper and brings nine spots that had been overlooked into line with the rest of the gem, so every response and error detail is now consistently symbol-keyed.
Because some calling code out there may currently rely on the old string-key behavior, this is a breaking change and the gem version is bumped accordingly.
Changes
Fixed the shared
Util.deep_symbolize_keyshelper so it recurses into arrays and not just nested hashes, matching how Rails' owndeep_transform_keysbehaves, so a list of records nested inside a response (for example a form schema'sfieldslist) now gets converted consistently.Added two shared helpers,
APIResource.symbolized_post/.symbolized_get, so any resource method that needs to hand back a plain result (rather than a full resource object) can run it through that same fix in one line instead of repeating the conversion by hand.Updated
Beneficiary.validate,.verify_account,.api_schema,.form_schema, and.supported_financial_institutionsto use those helpers, so callers get the same consistent access as every other Beneficiary method.Made the same fix to
ConnectedAccount.wallet_info,BillingCustomer#bank_transfer_instructions, andGlobalAccount#generate_statement_letter, closing out the remaining spots where a response was being handed back unconverted.Extended the fix to
Error#details, which previously held the raw, string-keyed error body even when everything else in the gem had moved to symbol keys.Bumped the gem to 0.8.0 and documented this as a breaking change in the changelog, since any code reading these responses (or error details) with string keys will need to switch to symbol keys.
Updated and added tests across the util, error, and affected resource specs to check symbol-key access, including inside nested lists, and corrected a batch transfer test that had unknowingly been depending on the old, buggy behavior.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.