Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base->toArray() expects array instead of null #336

Open
asdfklgash opened this issue Nov 8, 2023 · 1 comment
Open

Base->toArray() expects array instead of null #336

asdfklgash opened this issue Nov 8, 2023 · 1 comment
Labels

Comments

@asdfklgash
Copy link

General information

  • SDK/Library version: 6.9 and also 6.15
  • Environment: production (think sandbox also)
  • Language, language version, and OS: PHP 8.0 on Linux

Issue description

[TypeError]
array_map(): Argument #2 ($array) must be of type array, null given

Exception trace:
at /var/www/vendor/braintree/braintree_php/lib/Braintree/Base.php:101
array_map() at /var/www/vendor/braintree/braintree_php/lib/Braintree/Base.php:101
Braintree\Base->toArray() at /var/www/vendor/braintree/braintree_php/lib/Braintree/Base.php:97
Braintree\Base->Braintree{closure}() at n/a:n/a
array_map() at /var/www/vendor/braintree/braintree_php/lib/Braintree/Base.php:101
Braintree\Base->toArray() at /var/www/vendor/braintree/braintree_php/lib/Braintree/Base.php:97
Braintree\Base->Braintree{closure}() at n/a:n/a
array_map() at /var/www/vendor/braintree/braintree_php/lib/Braintree/Base.php:101
Braintree\Base->toArray() at ...

The problem occurs within your toArray() function when $this->_attributes is null as PHP expects array for array_map.
In our case the problem occurs with riskData->liabilityShift is null.
riskData->decisionReasons is an empty array for example and that works.

@hollabaq86
Copy link
Contributor

hollabaq86 commented Nov 27, 2023

👋 @asdfklgash sorry for the delay. We can absolutely fix up our code to be more defensive. Would you mind also contacting Technical Support, as I think something might have changed with our API that's resulting in this error in the SDK? They'll need recent example API calls where you've encountered this scenario so that they can find any related logs and communicate with our API engineering teams.

For internal tracking of SDK issue, ticket 29185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants