{"record":{"id":"5f75421f1d6136f5","repo":"microsoft/semantic-kernel","slug":"collection-has-no-connection-pool","errorCode":null,"errorMessage":"Collection has no connection pool.","messagePattern":"Collection has no connection pool\\.","errorType":"exception","errorClass":"VectorStoreOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/oracle.py","lineNumber":408,"sourceCode":"    async def __aenter__(self) -> \"OracleCollection\":\n        return self\n\n    @override\n    async def __aexit__(self, *args: Any) -> None:\n        # Only close the connection pool if it was created by the collection itself.\n        if self.managed_client and self.connection_pool:\n            try:\n                await self.connection_pool.close()\n            except Exception as e:\n                logger.warning(\"Error closing Oracle connection pool: %s\", e)\n            finally:\n                self.connection_pool = None\n                self.managed_client = False\n\n    def _check_pool(self) -> oracledb.AsyncConnectionPool:\n        \"\"\"Ensure that the connection pool is available, otherwise raise a consistent error.\"\"\"\n        if self.connection_pool is None:\n            raise VectorStoreOperationException(\"Collection has no connection pool.\")\n        return self.connection_pool\n\n    @override\n    def _deserialize_store_models_to_dicts(self, records: Sequence[Any], **kwargs: Any) -> Sequence[dict[str, Any]]:\n        \"\"\"Deserialize the store models to a list of dicts. Pass the records through without modification.\"\"\"\n        return records\n\n    def _full_table_name(self) -> str:\n        \"\"\"Return the fully qualified table name with optional schema prefix, quoted.\"\"\"\n        self._validate_identifiers(self.collection_name)\n        if self.db_schema:\n            self._validate_identifiers(self.db_schema)\n            return f'\"{self.db_schema}\".\"{self.collection_name}\"'\n        return f'\"{self.collection_name}\"'\n\n    async def _get_connection(self):\n        \"\"\"Acquire a connection from the pool, ensuring input/output type handlers are always set.\n","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/oracle.py#L390-L426","documentation":"Thrown by OracleCollection._check_pool when connection_pool is None - the pool was never created, or was set to None after __aexit__ closed a managed pool. Every DB operation funnels through _check_pool.","triggerScenarios":"Using the collection after `async with collection:` exited (which sets connection_pool=None for managed clients); constructing without creating a pool; calling operations on a collection whose pool failed to initialize.","commonSituations":"Forgetting the async context manager boundaries; reusing a collection after its managed pool was closed in __aexit__; passing connection_pool=None with settings that silently produced no pool.","solutions":["Ensure a valid connection_pool exists before invoking any collection operation","Use the collection inside an `async with` block, or pass a long-lived externally-managed pool","Do not reuse a collection after its __aexit__ closed the managed pool - construct a new one","If managing the pool externally, pass it via connection_pool= and keep it open for the collection's lifetime"],"exampleFix":"# before - collection used after pool closed\nasync with OracleCollection(record_type=MyModel) as col:\n    await col.ensure_collection_exists()\nawait col._inner_upsert([...])  # pool is now None -> 1512\n\n# after - perform all work inside the context\nasync with OracleCollection(record_type=MyModel) as col:\n    await col.ensure_collection_exists()\n    await col._inner_upsert([...])","handlingStrategy":"validation","validationCode":"def collection_has_pool(collection) -> bool:\n    return getattr(collection, 'connection_pool', None) is not None\n\nif not collection_has_pool(collection):\n    raise RuntimeError('Collection has no pool; reconstruct or pass a valid connection_pool')","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import VectorStoreOperationException\n\ntry:\n    await collection._inner_upsert(records)\nexcept VectorStoreOperationException as e:\n    if 'no connection pool' in str(e):\n        # reconstruct the collection or pass a fresh connection_pool\n        ...","preventionTips":["Perform all collection operations inside the `async with` block when using a managed pool","For long-lived collections, pass an externally-managed pool and keep it open","Never reuse a collection after __aexit__ closed its managed pool"],"tags":["oracle","connection","state","lifecycle"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}