Skip to content

fix/deep-symbolize-keys-arrays - #7

Merged
Rolguard merged 2 commits into
mainfrom
fix/deep-symbolize-keys-arrays
Sep 2, 2026
Merged

fix/deep-symbolize-keys-arrays#7
Rolguard merged 2 commits into
mainfrom
fix/deep-symbolize-keys-arrays

Conversation

@Rolguard

@Rolguard Rolguard commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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_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.

  • 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_institutions to 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, and GlobalAccount#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.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

…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.
@Rolguard
Rolguard merged commit 2a332d0 into main Sep 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants