Sentry-php: "No PSR-17 request factory found" exception

Created on 5 Mar 2020  路  3Comments  路  Source: getsentry/sentry-php

What's going on :thinking: :thinking:

When calling ClientBuilder->getClient(), it would fail because:

No PSR-17 request factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation

This is thrown all the way down in php-http/discovery here, which is failing because it can't find a library to do HTTP with.

There's two reasons for this:

  1. sentry-php changed to use guzzlehttp/psr7 instead of zendframework/zend-diactoros in v2.3.0

Replace dependency to zendframework/zend-diactoros with guzzlehttp/psr7 (#945)

  1. php-http/discovery can't actually discover guzzlehttp/psr7 (their issue reported here).

How to fix :) :)

weaverryan has pointed out in the php-http/discovery ticket that an interop library for guzzle exists called http-interop/http-factory-guzzle. By depending on that library instead of guzzle directly, then discovery will work and cheers will be had.
However, the interop library hasn't been updated in a hot minute, so perhaps Sentry would want to define the interop itself so it can use a newer version of guzzle? Perhaps you'd like to ping upstream to get them to update? I'm not sure, you call the shot :)

TL;DR:

Since Sentry 2.3.0, Sentry fails to run unless Sentry users happen to install the right HTTP library.
To solve this, depend on http-interop/http-factory-guzzle or implement its behaviour within sentry-php

Won't fix

Most helpful comment

After re-reading with more attention your first comment and the referenced issue in the php-http/discovery repository I now see the root cause of the problem and I think that it should be indeed fixed upstream. I will try to open a PR to get this fixed and see how it goes. I also just noticed that guzzlehttp/psr7 is exposing to Composer that it provides an implementation for psr/http-factory-implementation, thus making http-interop/http-factory-guzzle useless, but this change has not been released yet and this is why you get that error. It used to work in the past because zendframework/zend-diactoros did this from the beginning, so no extra package to make it working was needed

All 3 comments

sentry-php-sdk already requires the http-interop/http-factory-guzzle package in its composer.json. This package instead contains the source code of the core SDK, and should not force any implementation of an HTTP client because it's up to you to decide which you want to use: if you don't want to make this choice then the first package is the right one to pick.

Makes sense to me!

After re-reading with more attention your first comment and the referenced issue in the php-http/discovery repository I now see the root cause of the problem and I think that it should be indeed fixed upstream. I will try to open a PR to get this fixed and see how it goes. I also just noticed that guzzlehttp/psr7 is exposing to Composer that it provides an implementation for psr/http-factory-implementation, thus making http-interop/http-factory-guzzle useless, but this change has not been released yet and this is why you get that error. It used to work in the past because zendframework/zend-diactoros did this from the beginning, so no extra package to make it working was needed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

m1guelpf picture m1guelpf  路  7Comments

parichayawalia picture parichayawalia  路  3Comments

garak picture garak  路  4Comments

bojanpejic picture bojanpejic  路  3Comments

alksily picture alksily  路  7Comments