getsentry / sentry-symfony

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

Crash on install: missing nyholm/psr7 depencency #379

Closed soullivaneuh closed 3 years ago

soullivaneuh commented 4 years ago

I did a a setup of your bundle following the documentation provided by the user interface:

composer require sentry/sentry-symfony

Then my project crash with the following error:

Symfony\Component\Debug\Exception\ClassNotFoundException:
Attempted to load class "Psr17Factory" from namespace "Nyholm\Psr7\Factory".
Did you forget a "use" statement for another namespace?

  at var/cache/dev/ContainerHgJCfth/getDebug_SensioFrameworkExtra_Psr7_ArgumentValueResolver_ServerRequestService.php:9
  at require()
     (var/cache/dev/ContainerHgJCfth/srcApp_KernelDevDebugContainer.php:877)
  at ContainerHgJCfth\srcApp_KernelDevDebugContainer->load('getDebug_SensioFrameworkExtra_Psr7_ArgumentValueResolver_ServerRequestService.php')
     (var/cache/dev/ContainerHgJCfth/srcApp_KernelDevDebugContainer.php:1851)
  at ContainerHgJCfth\srcApp_KernelDevDebugContainer->ContainerHgJCfth\{closure}()
     (vendor/php/symfony/http-kernel/Controller/ArgumentResolver.php:51)
  at Symfony\Component\HttpKernel\Controller\ArgumentResolver->getArguments(object(Request), array(object(HostingController), 'indexAction'))
     (vendor/php/symfony/http-kernel/Controller/TraceableArgumentResolver.php:38)
  at Symfony\Component\HttpKernel\Controller\TraceableArgumentResolver->getArguments(object(Request), array(object(HostingController), 'indexAction'))
     (vendor/php/symfony/http-kernel/HttpKernel.php:150)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/php/symfony/http-kernel/HttpKernel.php:80)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/php/symfony/http-kernel/Kernel.php:201)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:34)

I solved the issue just by adding the right package:

composer require nyholm/psr7

You may have to fix your dependencies definition.

stayallive commented 4 years ago

@soullivaneuh can you share your full composer.json? This should not happen in theory 😄

soullivaneuh commented 4 years ago

Unfortunately, I live in France, not in Theory. I wish I could go there. :upside_down_face:

Here it is:

{
    "name": "xxx/xxx",
    "type": "project",
    "license": "proprietary",
    "autoload": {
        "psr-4": {
            "App\\": "src",
            "AppBundle\\": "src/AppBundle",
            "PowerDNSBundle\\": "src/PowerDNSBundle"
        },
        "files": [
            "src/env.php",
            "src/functions.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Dev\\": "src-dev/",
            "Tests\\AppBundle\\": "tests/AppBundle",
            "Tests\\PowerDNSBundle\\": "tests/PowerDNSBundle",
            "App\\Tests\\": "tests/"
        },
        "files": [
            "src/env_dev.php"
        ]
    },
    "require": {
        "php": "^7.4",
        "ext-PDO": "^7.1",
        "ext-bcmath": "^7.3",
        "ext-dom": "20031129",
        "ext-filter": "^7.1",
        "ext-hash": "^7.3",
        "ext-intl": "^7.3",
        "ext-json": "^7.4",
        "ext-openssl": "^7.1",
        "a2lix/translation-form-bundle": "^3.0",
        "algatux/influxdb-bundle": "^2.3",
        "api-platform/api-pack": "^1.1",
        "api-platform/core": "^2.3.5",
        "behat/transliterator": "^1.2",
        "browscap/browscap-bundle": "^1.0",
        "browscap/browscap-php": "^2.1",
        "cebe/markdown": "^1.1",
        "digitick/sepa-xml": "^1.0",
        "doctrine/annotations": "^1.6",
        "doctrine/cache": "^1.7",
        "doctrine/collections": "^1.5",
        "doctrine/common": "^2.9",
        "doctrine/dbal": "^2.6",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.3",
        "doctrine/doctrine-migrations-bundle": "^1.0",
        "doctrine/event-manager": "^1.0",
        "doctrine/inflector": "^1.3",
        "doctrine/migrations": "^1.6",
        "doctrine/orm": "^2.6",
        "doctrine/persistence": "^1.0",
        "egulias/email-validator": "^2.1",
        "eightpoints/guzzle-bundle": "^7.3",
        "emojione/emojione": "^4.0",
        "endroid/qr-code-bundle": "^3.3",
        "exsyst/swagger": "^0.4.0",
        "fabpot/goutte": "^3.0",
        "fig/link-util": "^1.0",
        "friendsofsymfony/jsrouting-bundle": "^2.1",
        "friendsofsymfony/user-bundle": "^2.0",
        "fusionauth/fusionauth-client": "^1.16",
        "giggsey/libphonenumber-for-php": "^8.9",
        "greg0ire/enum": "^4.0",
        "gregwar/image-bundle": "^2.1, >2.1.3",
        "guzzlehttp/guzzle": "^6.0",
        "hackzilla/password-generator": "^1.4",
        "hackzilla/password-generator-bundle": "^3.0",
        "hautelook/alice-bundle": "^2.0",
        "incenteev/composer-parameter-handler": "^2.0",
        "influxdb/influxdb-php": "^1.14",
        "inlinestyle/inlinestyle": "^1.2",
        "internations/solr-utils": "^0.8",
        "jms/translation-bundle": "^1.4",
        "knplabs/doctrine-behaviors": "^1.4",
        "knplabs/knp-components": "^1.3",
        "knplabs/knp-markdown-bundle": "^1.3",
        "knplabs/knp-menu": "^2.3",
        "knplabs/knp-menu-bundle": "^2.0",
        "knplabs/knp-paginator-bundle": "^2.4.3",
        "knpuniversity/oauth2-client-bundle": "^2.1",
        "kriswallsmith/spork": "^0.3",
        "lstrojny/fxmlrpc": "^0.15",
        "mck89/peast": "^1.8",
        "misd/phone-number-bundle": "^1.2",
        "monolog/monolog": "^1.23",
        "mtdowling/cron-expression": "^1.1",
        "nelmio/alice": "^3.4",
        "nesbot/carbon": "^2.37",
        "netresearch/jsonmapper": "^1.4",
        "nexylan/cloudflare": "^0.3",
        "nexylan/cloudflare-host-gw": "^0.2",
        "nexylan/gandi-sdk": "^0.4",
        "nexylan/graylog-sdk": "^0.6",
        "nexylan/nexycrypt": "^0.8.0",
        "nexylan/paybox-direct": "^0.3.7",
        "nexylan/slack": "^2.2",
        "nexylan/slack-bundle": "^2.1",
        "nyholm/psr7": "^1.3",
        "ornicar/gravatar-bundle": "^1.2",
        "paragonie/constant_time_encoding": "^2.3",
        "patchwork/utf8": "^1.3",
        "php-http/cache-plugin": "^1.5",
        "php-http/client-common": "^2.0",
        "php-http/guzzle6-adapter": "^2.0",
        "php-http/httplug": "^2.0",
        "php-http/httplug-bundle": "^1.11",
        "predis/predis": "^1.0",
        "psr/http-message": "^1.0",
        "psr/log": "^1.0",
        "psr/simple-cache": "^1.0",
        "ramsey/uuid": "^4.0",
        "rollerworks/password-strength-bundle": "^2.0",
        "rollerworks/password-strength-validator": "^1.0",
        "sensio/framework-extra-bundle": "^5.2",
        "sentry/sentry-symfony": "^3.5",
        "simplethings/entity-audit-bundle": "^1.0.1",
        "sllh/iso-codes-validator": "^4.0",
        "snc/redis-bundle": "^3.2.2",
        "sonata-project/admin-bundle": "^3.3",
        "sonata-project/block-bundle": "^3.12",
        "sonata-project/core-bundle": "^3.9",
        "sonata-project/doctrine-extensions": "^1.0",
        "sonata-project/doctrine-orm-admin-bundle": "^3.0.3",
        "sonata-project/exporter": "^1.9",
        "sonata-project/intl-bundle": "^2.2",
        "stof/doctrine-extensions-bundle": "^1.1",
        "swiftmailer/swiftmailer": "^6.0",
        "symfony/config": "^4.2",
        "symfony/console": "^4.3",
        "symfony/contracts": "^1.0",
        "symfony/dependency-injection": "^4.1, !=4.1.2, !=4.2.2",
        "symfony/doctrine-bridge": "^4.1",
        "symfony/dotenv": "^4.2",
        "symfony/event-dispatcher": "^4.1",
        "symfony/expression-language": "^4.1",
        "symfony/filesystem": "^4.1",
        "symfony/flex": "^1.0",
        "symfony/form": "^4.2",
        "symfony/framework-bundle": "^4.2",
        "symfony/http-foundation": "^4.4",
        "symfony/http-kernel": "^4.4",
        "symfony/intl": "^4.1",
        "symfony/lock": "^4.1",
        "symfony/monolog-bundle": "^3.0",
        "symfony/options-resolver": "^4.1",
        "symfony/process": "^4.1",
        "symfony/property-access": "^4.1",
        "symfony/property-info": "^4.1",
        "symfony/proxy-manager-bridge": "^4.1",
        "symfony/psr-http-message-bridge": "^1.0",
        "symfony/routing": "^4.1",
        "symfony/security": "^4.1, !=4.2.1",
        "symfony/security-bundle": "^4.1",
        "symfony/serializer": "^4.2",
        "symfony/swiftmailer-bundle": "^3.2",
        "symfony/templating": "^4.1",
        "symfony/translation": "^4.2",
        "symfony/twig-bridge": "^4.1",
        "symfony/twig-bundle": "^4.1",
        "symfony/validator": "^4.1",
        "symfony/web-link": "^4.2",
        "symfony/webpack-encore-bundle": "^1.0, !=1.1.0",
        "symfony/yaml": "^4.1",
        "thecodingmachine/gotenberg-php-client": "^6.1",
        "theofidry/alice-data-fixtures": "^1.0",
        "twig/extensions": "^1.0",
        "twig/twig": "^2.4",
        "webmozart/assert": "^1.2"
    },
    "require-dev": {
        "dama/doctrine-test-bundle": "^5.0",
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "fzaninotto/faker": "^1.7",
        "jolicode/gif-exception-bundle": "^1.4",
        "liip/functional-test-bundle": "^2.0",
        "php-http/mock-client": "^1.1",
        "roave/security-advisories": "dev-master",
        "sonata-project/easy-extends-bundle": "^2.5",
        "symfony/debug-bundle": "^4.0",
        "symfony/phpunit-bridge": "^4.3.4",
        "symfony/var-dumper": "^4.0",
        "symfony/web-profiler-bundle": "^4.0"
    },
    "conflict": {
        "api-platform/core": "2.5.4 - 2.5.5",
        "fzaninotto/faker": "<=1.5.0",
        "hautelook/alice-bundle": "2.1.0 - 2.2.0",
        "knplabs/knp-markdown-bundle": "1.5.0",
        "knplabs/knp-menu": "<=2.0.1",
        "liip/functional-test-bundle": ">=2.0.0-alpha4,<=2.0.0-alpha17",
        "sonata-project/doctrine-orm-admin-bundle": "3.6.0 - 3.9.0",
        "symfony/symfony": "*",
        "symfony/property-access": "4.1.9 || 4.2.0 - 4.2.1",
        "symfony/validator": "4.3.0",
        "theofidry/alice-data-fixtures": "1.1.0 - 1.1.2"
    },
    "scripts": {
        "init-scripts": [
            "./composer-scripts",
            "AppBundle\\Composer\\ScriptHandler::prepareParameters",
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ],
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd",
            "fos:js-routing:dump --target %PUBLIC_DIR%/routing.js": "symfony-cmd"
        },
        "post-install-cmd": [
            "@init-scripts",
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@init-scripts",
            "@auto-scripts"
        ]
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true,
        "vendor-dir": "vendor/php",
        "bin-dir": "vendor/bin"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "symfony": {
            "allow-contrib": true
        },
        "incenteev-parameters": {
            "file": "config/parameters.yaml",
            "dist-file": "config/parameters-dist.yaml"
        }
    }
}

Yes I know. Quite a lot of dependencies.

soullivaneuh commented 4 years ago

Also, the dependency installation brought me a new configuration on my project:

services:
  # Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories)
  Psr\Http\Message\RequestFactoryInterface: "@nyholm.psr7.psr17_factory"
  Psr\Http\Message\ResponseFactoryInterface: "@nyholm.psr7.psr17_factory"
  Psr\Http\Message\ServerRequestFactoryInterface: "@nyholm.psr7.psr17_factory"
  Psr\Http\Message\StreamFactoryInterface: "@nyholm.psr7.psr17_factory"
  Psr\Http\Message\UploadedFileFactoryInterface: "@nyholm.psr7.psr17_factory"
  Psr\Http\Message\UriFactoryInterface: "@nyholm.psr7.psr17_factory"

  # Register nyholm/psr7 services for autowiring with HTTPlug factories
  Http\Message\MessageFactory: "@nyholm.psr7.httplug_factory"
  Http\Message\RequestFactory: "@nyholm.psr7.httplug_factory"
  Http\Message\ResponseFactory: "@nyholm.psr7.httplug_factory"
  Http\Message\StreamFactory: "@nyholm.psr7.httplug_factory"
  Http\Message\UriFactory: "@nyholm.psr7.httplug_factory"

  nyholm.psr7.psr17_factory:
    class: Nyholm\Psr7\Factory\Psr17Factory

  nyholm.psr7.httplug_factory:
    class: Nyholm\Psr7\Factory\HttplugFactory

I'm not very confident with this. What is the impact? We already use PSR interfaces with http-plug without nyholm, I'm not sure why I need this.

Jean85 commented 4 years ago

The reason behind the PSR-7 requirement is due to sentry/sdk, which is required by this bundle and it's a metapackage that requires the base SDK (sentry/sentry) and also the suggested PSR packages needed for the HTTP transport.

If you don't like the suggested ones, since we rely on HTTPlug, you can replace sentry/sdk and just check that you require sentry/sentry and the PSR packages that you prefer directly.

[EDIT] This is documented here: https://github.com/getsentry/sentry-symfony#optional-use-custom-http-factorytransport

michaelzangerle commented 3 years ago

@Jean85 I am not sure if this is exactly the same problem but Google led me here. When I try to update to the newest version of this bundle (4.0) I get the following error from composer:

...
Run composer recipes at any time to see the status of your Symfony recipes.

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#463
!!    #message: """
!!      Attempted to load class "Psr17Factory" from namespace "Nyholm\Psr7\Factory".\n
!!      Did you forget a "use" statement for another namespace?
!!      """
!!    #code: 0
!!    #file: "./var/cache/dev/ContainerMohgFaa/App_KernelDevDebugContainer.php"
!!    #line: 12774
...

So if I understood you correctly the sentry/sdk package should take care of installing httplug because that's what sentry/sentry is using and requires. Taking a look at packagist I see that sentry/sdk requires symfony/http-client and sentry/sentry requires php-http/httplug. I really don't care which one of both is used, but I did expect the bundle to require all dependencies which are needed.

Replacing sentry/sdk in composer as explained in the docs fixes this issue but triggers another one:

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  TypeError {#12710
!!    #message: "Jean85\Version::__construct(): Argument #3 ($reference) must be of type string, null given, called in /var/www/app/vendor/jean85/pretty-package-versions/src/PrettyVersions.php on line 16"
!!    #code: 0
!!    #file: "./vendor/jean85/pretty-package-versions/src/Version.php"
!!    #line: 23
!!    trace: {
!!      ./vendor/jean85/pretty-package-versions/src/Version.php:23 { …}
!!      ./vendor/jean85/pretty-package-versions/src/PrettyVersions.php:16 { …}
!!      ./vendor/jean85/pretty-package-versions/src/PrettyVersions.php:27 { …}
!!      ./vendor/sentry/sentry-symfony/src/DependencyInjection/Configuration.php:76 { …}
!!      ./vendor/symfony/config/Definition/Processor.php:50 { …}
!!      ./vendor/symfony/dependency-injection/Extension/Extension.php:111 { …}
!!      ./vendor/symfony/http-kernel/DependencyInjection/ConfigurableExtension.php:35 { …}
!!      ./vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php:76 { …}
!!      ./vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php:39 { …}
!!      ./vendor/symfony/dependency-injection/Compiler/Compiler.php:91 { …}
!!      ./vendor/symfony/dependency-injection/ContainerBuilder.php:736 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:541 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:780 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:121 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
!!      ./vendor/symfony/console/Application.php:166 { …}
!!      ./bin/console:43 {
!!        › $application = new Application($kernel);
!!        › $application->run($input);
!!        › 
!!        arguments: {
!!          $input: Symfony\Component\Console\Input\ArgvInput {#6 …}
!!        }
!!      }
!!    }
!!  }

Any idea what's wrong here? :thinking:

Jean85 commented 3 years ago

You should report which versions of the involved packages are you using. Nyholm's packages are no longer used, neither here not in sentry-php...

michaelzangerle commented 3 years ago

Sorry I didn't make that clear enough. I don't use any of those dependencies directly. I just upgraded the Sentry Symfony bundle from 3.5 to 4.0 after upgrading to PHP 8. Not using pretty-page-versions nor Nyholms package.

Tried to ensure that the issue is not related to something else and removed sentry completely. Updating all other dependencies worked. Tried adding sentry with the dependencies below ...

    "require": {
        "php": "^8.0",
        "ext-ctype": "*",
        "ext-json": "*",
        "composer-runtime-api": "^2.0",
        "brick/math": "^0.8",
        "doctrine/doctrine-bundle": "^2.1",
        "doctrine/doctrine-fixtures-bundle": "^3.3",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.7",
        "egulias/email-validator": "^2.1",
        "friendsofsymfony/rest-bundle": "^3.0",
        "fusonic/http-kernel-extensions": "^1.0",
        "jms/serializer-bundle": "^3.8",
        "league/flysystem-aws-s3-v3": "^1.0",
        "liip/imagine-bundle": "2.x-dev",
        "nelmio/api-doc-bundle": "^4.0",
        "oneup/flysystem-bundle": "^3.5",
        "sensio/framework-extra-bundle": "^5.6",
        "sulu/validation-bundle": "1.0",
        "symfony/amazon-mailer": "^5.2",
        "symfony/asset": "^5.2",
        "symfony/debug-bundle": "^5.2",
        "symfony/doctrine-messenger": "^5.2",
        "symfony/dotenv": "^5.2",
        "symfony/event-dispatcher": "^5.2",
        "symfony/expression-language": "^5.2",
        "symfony/flex": "^1.9",
        "symfony/lock": "^5.2",
        "symfony/mailer": "^5.2",
        "symfony/messenger": "^5.2",
        "symfony/monolog-bundle": "^3.5",
        "symfony/security-bundle": "^5.2",
        "symfony/security-csrf": "^5.2",
        "symfony/serializer-pack": "^1.0",
        "symfony/translation": "^5.2",
        "symfony/twig-bundle": "^5.2",
        "symfony/validator": "^5.2",
        "symfony/workflow": "^5.2",
        "symfony/yaml": "^5.2"
    },
    "require-dev": {
        "blackfire/php-sdk": "^1.23",
        "friendsofphp/php-cs-fixer": "^2.16",
        "phpstan/phpstan": "^0.12",
        "phpstan/phpstan-doctrine": "^0.12",
        "phpunit/phpunit": "^9.2",
        "roave/security-advisories": "dev-master",
        "symfony/test-pack": "^1.0"
    },

... and here the full output from composer:

root@7b19f78d065c:/var/www/app# composer require sentry/sentry-symfony
Using version ^4.0 for sentry/sentry-symfony
./composer.json has been updated
Running composer update sentry/sentry-symfony
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "^5.2"
Updating dependencies
Lock file operations: 16 installs, 0 updates, 0 removals
  - Locking clue/stream-filter (v1.5.0)
  - Locking http-interop/http-factory-guzzle (1.0.0)
  - Locking jean85/pretty-package-versions (1.5.1)
  - Locking php-http/client-common (2.3.0)
  - Locking php-http/discovery (1.13.0)
  - Locking php-http/httplug (2.2.0)
  - Locking php-http/message (1.10.0)
  - Locking php-http/message-factory (v1.0.2)
  - Locking php-http/promise (1.1.0)
  - Locking psr/http-factory (1.0.1)
  - Locking sentry/sdk (3.1.0)
  - Locking sentry/sentry (3.1.2)
  - Locking sentry/sentry-symfony (4.0.0)
  - Locking symfony/http-client (v5.2.1)
  - Locking symfony/polyfill-uuid (v1.22.0)
  - Locking symfony/psr-http-message-bridge (v2.0.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 16 installs, 0 updates, 0 removals
  - Installing clue/stream-filter (v1.5.0): Extracting archive
  - Installing psr/http-factory (1.0.1): Extracting archive
  - Installing http-interop/http-factory-guzzle (1.0.0): Extracting archive
  - Installing php-http/message-factory (v1.0.2): Extracting archive
  - Installing php-http/promise (1.1.0): Extracting archive
  - Installing symfony/polyfill-uuid (v1.22.0): Extracting archive
  - Installing php-http/message (1.10.0): Extracting archive
  - Installing php-http/httplug (2.2.0): Extracting archive
  - Installing php-http/discovery (1.13.0): Extracting archive
  - Installing php-http/client-common (2.3.0): Extracting archive
  - Installing symfony/http-client (v5.2.1): Extracting archive
  - Installing jean85/pretty-package-versions (1.5.1): Extracting archive
  - Installing sentry/sentry (3.1.2): Extracting archive
  - Installing symfony/psr-http-message-bridge (v2.0.2): Extracting archive
  - Installing sentry/sdk (3.1.0)
  - Installing sentry/sentry-symfony (4.0.0): Extracting archive
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
132 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Symfony operations: 1 recipe (739d07bca5b086671320ad7b7400c399)
  -  WARNING  sentry/sentry-symfony (>=3.0): From github.com/symfony/recipes-contrib:master
    The recipe for this package comes from the "contrib" repository, which is open to community contributions.
    Review the recipe at https://github.com/symfony/recipes-contrib/tree/master/sentry/sentry-symfony/3.0

    Do you want to execute this recipe?
    [y] Yes
    [n] No
    [a] Yes for all packages, only for the current installation session
    [p] Yes permanently, never ask again for this project
    (defaults to n): y
  - Configuring sentry/sentry-symfony (>=3.0): From github.com/symfony/recipes-contrib:master
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#7268
!!    #message: """
!!      Attempted to load class "Psr17Factory" from namespace "Nyholm\Psr7\Factory".\n
!!      Did you forget a "use" statement for another namespace?
!!      """
!!    #code: 0
!!    #file: "./var/cache/dev/ContainerQd0cMbJ/App_KernelDevDebugContainer.php"
!!    #line: 12774
!!    trace: {
!!      ./var/cache/dev/ContainerQd0cMbJ/App_KernelDevDebugContainer.php:12774 {
!!        ContainerQd0cMbJ\App_KernelDevDebugContainer->getSensioFrameworkExtra_Psr7_HttpMessageFactoryService()
!!        › {
!!        ›     $a = ($this->privates['nyholm.psr7.psr17_factory'] ?? ($this->privates['nyholm.psr7.psr17_factory'] = new \Nyholm\Psr7\Factory\Psr17Factory()));
!!        › 
!!      }
!!      ./var/cache/dev/ContainerQd0cMbJ/App_KernelDevDebugContainer.php:8221 { …}
!!      ./var/cache/dev/ContainerQd0cMbJ/App_KernelDevDebugContainer.php:8165 { …}
!!      ./var/cache/dev/ContainerQd0cMbJ/App_KernelDevDebugContainer.php:2426 { …}
!!      ./vendor/symfony/event-dispatcher/EventDispatcher.php:245 { …}
!!      ./vendor/symfony/event-dispatcher/EventDispatcher.php:76 { …}
!!      ./vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:290 { …}
!!      ./vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:145 { …}
!!      ./vendor/symfony/console/Application.php:986 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:96 { …}
!!      ./vendor/symfony/console/Application.php:290 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:82 { …}
!!      ./vendor/symfony/console/Application.php:166 { …}
!!      ./bin/console:43 { …}
!!    }
!!  }
!!  2021-01-24T10:27:09+00:00 [info] User Deprecated: The "Sentry\State\HubAdapter::startTransaction()" method will require a new "array<string, mixed> $customSamplingContext" argument in the next major version of its interface "Sentry\State\HubInterface", not defining it is deprecated.
!!  2021-01-24T10:27:09+00:00 [info] User Deprecated: The "Sentry\State\Hub::startTransaction()" method will require a new "array<string, mixed> $customSamplingContext" argument in the next major version of its interface "Sentry\State\HubInterface", not defining it is deprecated.
!!  2021-01-24T10:27:09+00:00 [critical] Uncaught Error: Class "Nyholm\Psr7\Factory\Psr17Factory" not found
!!  
Script @auto-scripts was called via post-update-cmd

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Requiring both (Sentry and Nyhom/PRS7) makes composer run through but that doesn't feel like a good solution.

ste93cry commented 3 years ago

Looking at the stacktrace, the issue is related to the SensioFrameworkExtraBundle bundle

https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/710

michaelzangerle commented 3 years ago

@ste93cry Thanks.

In case somebody else stumbles upon this issue the situation is described here and a workaround is provided as well.

VincentLanglet commented 3 years ago

It could be nice to add in the UPGRADE note to add

sensio_framework_extra:
    psr_message:
        enabled: false
ste93cry commented 3 years ago

I don't think we should add this to the docs, the problem doesn't clearly belongs to this bundle and should be solved upstream. In fact, if you don't have the FrameworkExtraBundle bundle installed everything would be fine

VincentLanglet commented 3 years ago

I don't think we should add this to the docs, the problem doesn't clearly belongs to this bundle and should be solved upstream. In fact, if you don't have the FrameworkExtraBundle bundle installed everything would be fine

Even if it's not related to this bundle, It's about helping the users to upgrade. I took 1 hour to solve this issue. One hour which could be saved with two lines in the Upgrade doc. Do you like your users and wants to help them or not ? ;)

Jean85 commented 3 years ago

The point is that it's not due to this bundle. It's an issue of indirect dependencies: we required that, but upgrading (not this bundle but the sentry/sdk package) triggers the removal of such dependency.

Then, the ExtraBundle breaks.

So, I don't know what we could report there... I'm open to a PR to evaluate on a proper text.

mbabker commented 3 years ago

So, I don't know what we could report there... I'm open to a PR to evaluate on a proper text.

Maybe just an extra note? The PSR-7 bit seems to be going away in a forthcoming 6.0 release, but until that's released this is just an extra thing folks have to keep in mind.

"If you have SensioFrameworkExtraBundle < 6.0 installed and are not using its PSR-7 feature, you will need to disable it in your application's configuration or there will most likely be a crash due to missing dependencies, you can fix this by adding this to the bundle's configuration:" (then the snippet posted in https://github.com/getsentry/sentry-symfony/issues/379#issuecomment-768184584 goes here).

TBH, the error itself isn't all that bad and I don't think anyone's intent is to play the blame game on who's wrong; I actually am more surprised the Sensio bundle had that feature enabled by default than the fact I got an error related to that after upgrading the Sentry bundle.

Bilge commented 3 years ago

For me, the solution was just to delete psr_http_message_bridge.yaml, which some stupid flex recipe thing had produced for no good reason, breaking my application referencing non-existent services.