RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(connector): honor configured S3-compatible bucket type (#18576)
Jiaquan Yi3023e2f3e3ae
diff --git a/common/data_source/__init__.py b/common/data_source/__init__.pyindex f0865a3ead..6d833c8332 100644--- a/common/data_source/__init__.py+++ b/common/data_source/__init__.py@@ -111,7 +111,7 @@ def build_connector_for_source(source: str, config: dict[str, Any]) -> Any:if connector_cls is None:raise ConnectorValidationError(f"Unsupported data source type: {source}")if connector_cls is BlobStorageConnector:- return connector_cls.build_connector(config, bucket_type=source)+ return connector_cls.build_connector(config, bucket_type=config.get("bucket_type") or source)if connector_cls is RDBMSConnector:return connector_cls.build_connector(config, db_type=source)return connector_cls.build_connector(config)diff --git a/test/unit_test/common/test_data_source_factory.py b/test/unit_test/common/test_data_source_factory.pynew file mode 100644index 0000000000..edffe9cec7--- /dev/null+++ b/test/unit_test/common/test_data_source_factory.py@@ -0,0 +1,54 @@+"""Tests for data-source connector construction."""++import pytest++from common import settings # noqa: F401 - initialize shared settings before connector imports+from common.constants import FileSource+from common.data_source import BlobStorageConnector, build_connector_for_source+++def test_s3_connector_uses_configured_compatible_bucket_type(monkeypatch):+ captured = {}+ expected = object()++ def build_connector(config, *, bucket_type):+ captured["config"] = config+ captured["bucket_type"] = bucket_type+ return expected++ monkeypatch.setattr(BlobStorageConnector, "build_connector", build_connector)+ config = {"bucket_name": "database", "bucket_type": "s3_compatible"}++ connector = build_connector_for_source(FileSource.S3, config)++ assert connector is expected+ assert captured == {"config": config, "bucket_type": "s3_compatible"}+++def test_s3_connector_defaults_bucket_type_to_source(monkeypatch):+ captured = {}++ def build_connector(_config, *, bucket_type):+ captured["bucket_type"] = bucket_type+ return object()++ monkeypatch.setattr(BlobStorageConnector, "build_connector", build_connector)++ build_connector_for_source(FileSource.S3, {"bucket_name": "database"})++ assert captured["bucket_type"] == FileSource.S3++[email protected]("configured_bucket_type", [None, ""])+def test_s3_connector_defaults_empty_bucket_type_to_source(monkeypatch, configured_bucket_type):+ captured = {}++ def build_connector(_config, *, bucket_type):+ captured["bucket_type"] = bucket_type+ return object()++ monkeypatch.setattr(BlobStorageConnector, "build_connector", build_connector)++ build_connector_for_source(FileSource.S3, {"bucket_name": "database", "bucket_type": configured_bucket_type})++ assert captured["bucket_type"] == FileSource.S3