{"record":{"id":"8a465f140222c269","repo":"mongodb/laravel-mongodb","slug":"the-database-connection-s-does-not-use-the-mongodb-driver","errorCode":null,"errorMessage":"The database connection \"%s\" does not use the \"mongodb\" driver.","messagePattern":"The database connection \"(.+?)\" does not use the \"mongodb\" driver\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/MongoDBServiceProvider.php","lineNumber":136,"sourceCode":"        $this->app->resolving('filesystem', static function (FilesystemManager $filesystemManager) {\n            $filesystemManager->extend('gridfs', function (Application $app, array $config) {\n                if (! class_exists(GridFSAdapter::class)) {\n                    throw new RuntimeException('GridFS adapter for Flysystem is missing. Try running \"composer require league/flysystem-gridfs\"');\n                }\n\n                $bucket = $config['bucket'] ?? null;\n\n                if ($bucket instanceof Closure) {\n                    // Get the bucket from a factory function\n                    $bucket = $bucket($app, $config);\n                } elseif (is_string($bucket) && $app->has($bucket)) {\n                    // Get the bucket from a service\n                    $bucket = $app->get($bucket);\n                } elseif (is_string($bucket) || $bucket === null) {\n                    // Get the bucket from the database connection\n                    $connection = $app['db']->connection($config['connection']);\n                    if (! $connection instanceof Connection) {\n                        throw new InvalidArgumentException(sprintf('The database connection \"%s\" does not use the \"mongodb\" driver.', $config['connection'] ?? $app['config']['database.default']));\n                    }\n\n                    $bucket = $connection->getClient()\n                        ->getDatabase($config['database'] ?? $connection->getDatabaseName())\n                        ->selectGridFSBucket(['bucketName' => $config['bucket'] ?? 'fs', 'disableMD5' => true]);\n                }\n\n                if (! $bucket instanceof Bucket) {\n                    throw new InvalidArgumentException(sprintf('Unexpected value for GridFS \"bucket\" configuration. Expecting \"%s\". Got \"%s\"', Bucket::class, get_debug_type($bucket)));\n                }\n\n                $adapter = new GridFSAdapter($bucket, $config['prefix'] ?? '');\n\n                /** @see FilesystemManager::createFlysystem() */\n                if ($config['read-only'] ?? false) {\n                    if (! class_exists(ReadOnlyFilesystemAdapter::class)) {\n                        throw new RuntimeException('Read-only Adapter for Flysystem is missing. Try running \"composer require league/flysystem-read-only\"');\n                    }","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/mongodb/laravel-mongodb/blob/0634653039468ceb0268a69192bdac64469ed043/src/MongoDBServiceProvider.php#L118-L154","documentation":"Thrown while registering the 'gridfs' Flysystem disk when the connection named in the disk config (config['connection'] or similar) is not backed by the 'mongodb' driver. GridFS buckets can only live on MongoDB, so a mysql/pgsql/sqlite connection is rejected before the bucket is resolved; the error names the offending connection.","triggerScenarios":"Thrown at src/MongoDBServiceProvider.php:136 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Point the gridfs disk config in config/filesystems.php at a connection whose driver is 'mongodb'.","Verify the connection name spelled in the disk's 'connection' option exists in config/database.php and uses driver 'mongodb'.","Add a dedicated MongoDB connection for GridFS storage and reference it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0634653039468ceb0268a69192bdac64469ed043","analyzedAt":"2026-09-15T02:56:37.067Z","contentChangedAt":"2026-09-15T02:56:37.067Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}