Search code examples
phppodio

Podio error when getting apps


Error
ErrorException: array_merge(): Argument #1 is not an array in /my/server/vendor/podio/podio-php/lib/PodioObject.php:200
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'array_merge(): ...', '/my/server/...', 200, Array)
#1 /my/server/vendor/podio/podio-php/lib/PodioObject.php(200): array_merge(NULL, Array)
#2 /my/server/vendor/podio/podio-php/models/PodioApp.php(39): PodioObject::member(Object(PodioResponse))
#3 /my/path.php(413): PodioApp::get(xxxxxxx)

This appears to be a bug with the Podio PHP SDK or Podio API. The json_response (which is causing the array_merge error) is null, yet the http response is 200. I cannot get it to occur regularly, however it occurs roughly 10% of the time on script that is running 30~ of these calls. I can run the GetApp call directly from the documentation just fine.

I know it's an error with the responses because my script breaks at different places on each rerun depending on which data hasn't been loaded from the API correctly.

Test 1: Exception at line 344 as the result of $app1 being null

Test 2: Exception at line 814 as the result of $app3 being null

etc...

This is a script that was not modified and has been in place for over 6 months, but stopped working sometime last week.

EDIT: I've also confirmed that the same error occurs with cURL, so it isn't an SDK-specific issue.


Solution

  • This intermittent errors should not be happening anymore :)
    Unless your network connection is unstable or choppy.

    Anyway it's good to have proper handling for network-dependent calls (like any Podio API call). I can only suggest that all Podio API calls should go through queueing mechanism that will allow retry in case if network is unstable or Podio is on maintenance (as example).