botman / botman/driver-facebook

Trying to access array offset on value of type null

Open
#118 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
71
Forks
72
PR merge metrics
No merged PRs in 30d

Description

- BotMan Version: 2.6.1
- PHP Version: 7.4.25
- Messaging Service(s):
- Cache Driver:
- FacebookDriver: 1.11.0

### Description:
Error when calling chatbot with FacebookDriver:

local.ERROR: Trying to access array offset on value of type null {"exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type null at .......vendor/botman/driver-facebook/src/FacebookDriver.php:516)

So in FacebookDriver:
$facebookResponse->getContent() return nothing
$facebookResponse->getStatusCode() = 500

protected function throwExceptionIfResponseNotOk(Response $facebookResponse)
{
if ($facebookResponse->getStatusCode() !== 200) {
$responseData = json_decode($facebookResponse->getContent(), true);
throw new FacebookException('Error sending payload: '.$responseData['error']['message']);
}
}

### Steps To Reproduce:
Facebook driver tutorial

Contributor guide

Open the contributing guide

Research direction

Start with vendor/botman/driver-facebook/src/FacebookDriver.php around line 516 and inspect throwExceptionIfResponseNotOk. Reproduce the failure using the Facebook driver tutorial, then verify that a non-200 response with empty content no longer triggers an array-offset error and produces an appropriate exception message.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.