getsentry / sentry-symfony

The official Symfony SDK for Sentry (sentry.io)
https://sentry.io
MIT License
695 stars 171 forks source link

Uri class not found #707

Closed micheh closed 1 year ago

micheh commented 1 year ago

With the release of sentry/sentry 3.17, guzzlehttp/psr7 is no longer installed when using the Symfony http client.

This is nice, but leads to an error in this package, as GuzzleHttp\Psr7\Uri is still used in the AbstractTraceableHttpClient:

https://github.com/getsentry/sentry-symfony/blob/bcdbd3d13376473a514c0ec97566b0c7cdc5a1fc/src/Tracing/HttpClient/AbstractTraceableHttpClient.php#L54

Maybe the http client can be updated to allow nyholm/psr7 as well or this package should explicitly require guzzlehttp/psr7?

stayallive commented 1 year ago

This is interesting though, we still require sentry/sdk (here in the Symfony integration) which requires http-interop/http-factory-guzzle which requires guzzlehttp/psr7.

So I'm not a 100% sure why the Guzzle library would be missing (even though we should probably require it directly instead anyway since we use it explicitly) unless the php-http plugin somehow removes it.

I tried it with a fresh Symfony application and composer require sentry/sentry-symfony still proceeds to install guzzlehttp/psr7. Anything I'm missing?

micheh commented 1 year ago

I have added a replacement for the sentry/sdk, as mentioned in the readme (to use the Symfony http client and nyholm/psr7):

"replace": {
    "sentry/sdk": "*"
}

Once this is removed, guzzlehttp/psr7 is indeed installed through the sdk package. With sentry/sentry 3.16.0, guzzlehttp/psr7 was installed even with the replacement, but sentry/sentry 3.17.0 removes the psr7 package and you'll have to remove the replacement of sentry/sdk to install the psr7 package again.

stayallive commented 1 year ago

That was the missing part, sorry I missed that. In any case we should directly depend on guzzlehttp/psr7 so I've opened #708 to fix that.

But I've also opened #709 since those instructions in the readme are outdated, our own sentry/sdk metapackage ships with the Symfony HTTP client these days so there is no reason to replace that package anymore (for that purpose).

So in your case you can remove the replace for sentry/sdk (and possibly remove the dependency on pugx/sentry-sdk if you ever had that) and it should "fix" the issue for you but ofcourse #708 will fix it correctly if sentry/sdk is ever being replaced or switches it's PSR7 dependency 👍