You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get the following error when running my unit tests:
TypeError: Honeybadger\HoneybadgerLaravel\HoneybadgerLaravel::setRouteActionAndUserContext(): Argument #1 ($request) must be of type Symfony\Component\HttpFoundation\Request, Illuminate\Support\Facades\Request given, called in /srv/app.vanilo.cloud/vendor/honeybadger-io/honeybadger-laravel/src/HoneybadgerLaravel.php on line 63
I think the setRouteActionAndUserContext() shouldn't be called at all if shouldReport() returns false. (I'm not sure about this condition though)
I believe this version of the notify method would fix the issue and would be more optimal:
publicfunctionnotify(Throwable$throwable, ?Request$request = null, array$additionalParams = []): array
{
// CHANGE 1: Return early if reporting is disabledif (! $this->shouldReport($throwable)) {
return [];
}
// CHANGE 2: Use the Request facade's instance() method as a fallback request resolver$this->setRouteActionAndUserContext($request ?: \Illuminate\Support\Facades\Request::instance());
$result = parent::notify($throwable, $request, $additionalParams);
// Persist the most recent error for the rest of the request, so we can display on error page.if (app()->bound('session')) {
// Lumen doesn't come with sessions.session()->now('honeybadger_last_error', $result['id'] ?? null);
}
return$result;
}
Next Steps
I'd be happy to submit a PR, but I wanted to get your input first on whether it's a good direction.
The text was updated successfully, but these errors were encountered:
Error Description
I get the following error when running my unit tests:
I am using version 4.4.0 of the library.
Possible Solution
I think we have two issues here: https://github.com/honeybadger-io/honeybadger-laravel/blob/v4.4.0/src/HoneybadgerLaravel.php#L63
request()
call may return the facade, not the resolved request object. I guess the following code would be better:setRouteActionAndUserContext()
shouldn't be called at all ifshouldReport()
returns false. (I'm not sure about this condition though)I believe this version of the notify method would fix the issue and would be more optimal:
Next Steps
I'd be happy to submit a PR, but I wanted to get your input first on whether it's a good direction.
The text was updated successfully, but these errors were encountered: