Open manurwx opened 11 months ago
Hi @manurwx! Can you please provide your code which you are using so that we can reproduce the error? Thanks!
Hi @manurwx! Can you please provide your code which you are using so that we can reproduce the error? Thanks!
Hi, we use it in a commercial product so I can't share the code other than this line which triggers the error in our system:
return $this->client->taskrouter->v1->workspaces($this->workspaceSid)->tasks($taskSid)->update($attributes);
This is the error:
TypeError
Twilio\Rest\Taskrouter\V1\Workspace\TaskInstance::__construct(): Argument #2 ($payload) must be of type array, null given, called in /src/vendor/twilio/sdk/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskContext.php on line 85
It's pretty clear that the issue is in the implementation of update()
method in vendor/twilio/sdk/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskContext.php
It wrongly assumes that its internal $payload
variable is always of array type, where in fact there are instances where it can actually be null
. So when $payload
happens to be null
and it goes on to create a TaskInstance
object passing a null
payload as parameter it breaks.
Issue Summary
This is the error we've been seeing in our prod environment
Suspected cause
The payload (second argument) to
TaskInstance
constructor is generated bygetContent()
method invendor/twilio/sdk/src/Twilio/Http/Response.php:22
all
getContent()
method does is to calljson_decode()
and according to PHP docs the only instances where it returnsnull
is if it cannot decode the json string or max depth (default to 512) gets exceeded. Either way seems like the SDK is not handling this edge case causing aTypeError
exception when it happens.Exception/Log
Technical details: