Skip to content

Version 4.0: Connection "default" is not defined #168

@peterjaap

Description

@peterjaap

When upgrading from Sentry module 3.9 to 4.0, we're suddenly getting Connection "default" is not defined errors in our patch helper and static testing pipelines (which obviously don't have a database set up).

$ php bin/magento module:config:status
In ResourceConnection.php line [161](https://gitlab.elgentos.nl/pluim/magento2/-/jobs/1268210#L161):
                                       
  Connection "default" is not defined

We see this consistently in 10+ projects (Magento 2.4.7-p5 and 2.4.8 on PHP 8.3). A clue is that we only see this in CI, locally we can't seem to reproduce it yet.

Apparently, the changes done from 3.9 to 4.0 introduce something that requires a database connection on instantiation. But I can't find/see what it its in the diff.

I'm suspecting the newly introduced JustBetter\Sentry\Model\Collector\SentryRelatedCspCollector. That file injects the JustBetter\Sentry\Helper\Data, which has these deps;

    public function __construct(
        Context $context,
        protected StoreManagerInterface $storeManager,
        protected State $appState,
        private Json $serializer,
        protected ProductMetadataInterface $productMetadataInterface,
        protected DeploymentConfig $deploymentConfig
    ) {

I think one of these deps forces a database connection.

That non-nullable deploymentConfig might be it. In JustBetter\Sentry\Helper\Version that one is nullable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions