LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
UN-2362-s3-connector-fix (#1301)
Kirtiman Mishra7b8b66fdb68c
diff --git a/unstract/connectors/src/unstract/connectors/filesystems/minio/exceptions.py b/unstract/connectors/src/unstract/connectors/filesystems/minio/exceptions.pyindex 2b9b6ea0a..0cc1a8977 100644--- a/unstract/connectors/src/unstract/connectors/filesystems/minio/exceptions.py+++ b/unstract/connectors/src/unstract/connectors/filesystems/minio/exceptions.py@@ -10,10 +10,28 @@ S3FS_EXC_TO_UNSTRACT_EXC = {"[Errno 22] S3 API Requests must be made to API port": ( # Minio only"Request made to invalid port, please check the port of the endpoint URL."),+ "Invalid endpoint": (+ "Could not connect to the endpoint URL. Please check if the URL is correct "+ "and accessible."+ ),}def handle_s3fs_exception(e: Exception) -> ConnectorError:+ """Parses the exception from S3/MinIO.++ Helps parse the S3/MinIO error and wraps it with our+ custom exception object to contain a user friendly message.++ Args:+ e (Exception): Error from S3/MinIO++ Returns:+ ConnectorError: Unstract's ConnectorError object+ """+ if isinstance(e, ConnectorError):+ return e+original_exc = str(e)user_msg = "Error from S3 / MinIO while testing connection: "exc_to_append = ""@@ -22,5 +40,8 @@ def handle_s3fs_exception(e: Exception) -> ConnectorError:exc_to_append = user_friendly_msgbreak- user_msg += exc_to_append if exc_to_append else str(e)+ # Generic error handling+ user_msg += (+ f"\n```\n{exc_to_append}\n```" if exc_to_append else f"\n```\n{str(e)}\n```"+ )return ConnectorError(message=user_msg)diff --git a/unstract/connectors/src/unstract/connectors/filesystems/minio/minio.py b/unstract/connectors/src/unstract/connectors/filesystems/minio/minio.pyindex 43d66a411..8531565fd 100644--- a/unstract/connectors/src/unstract/connectors/filesystems/minio/minio.py+++ b/unstract/connectors/src/unstract/connectors/filesystems/minio/minio.py@@ -14,9 +14,9 @@ logger = logging.getLogger(__name__)class MinioFS(UnstractFileSystem):def __init__(self, settings: dict[str, Any]):super().__init__("MinioFS/S3")- key = settings["key"]- secret = settings["secret"]- endpoint_url = settings["endpoint_url"]+ key = settings.get("key", "")+ secret = settings.get("secret", "")+ endpoint_url = settings.get("endpoint_url", "")client_kwargs = {}if "region_name" in settings and settings["region_name"] != "":client_kwargs = {"region_name": settings["region_name"]}@@ -99,9 +99,7 @@ class MinioFS(UnstractFileSystem):def test_credentials(self) -> bool:"""To test credentials for Minio."""try:- is_dir = bool(self.get_fsspec_fs().isdir(""))- if not is_dir:- raise RuntimeError("Could not access root directory.")+ self.get_fsspec_fs().ls("")except Exception as e:raise handle_s3fs_exception(e) from ereturn True