Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: replace bare except with except Exception in core agent, storage and vector backends (#40801)

Dream8031ea6d7370
diff --git a/api/core/agent/output_parser/cot_output_parser.py b/api/core/agent/output_parser/cot_output_parser.py
index f341ca5a0be..c7e1252ad14 100644
--- a/api/core/agent/output_parser/cot_output_parser.py
+++ b/api/core/agent/output_parser/cot_output_parser.py
@@ -49,7 +49,7 @@ class CotAgentOutputParser:
json_text = re.sub(r"^[a-zA-Z]+\n", "", block.strip(), flags=re.MULTILINE)
json_blocks.append(json.loads(json_text, strict=False))
return json_blocks
- except:
+ except Exception:
return []
code_block_cache = ""
diff --git a/api/extensions/storage/aws_s3_storage.py b/api/extensions/storage/aws_s3_storage.py
index cf69f82bce1..fc6f70469ab 100644
--- a/api/extensions/storage/aws_s3_storage.py
+++ b/api/extensions/storage/aws_s3_storage.py
@@ -86,7 +86,7 @@ class AwsS3Storage(BaseStorage):
try:
self.client.head_object(Bucket=self.bucket_name, Key=filename)
return True
- except:
+ except Exception:
return False
@override
diff --git a/api/extensions/storage/oracle_oci_storage.py b/api/extensions/storage/oracle_oci_storage.py
index cee66479494..70c93b48b64 100644
--- a/api/extensions/storage/oracle_oci_storage.py
+++ b/api/extensions/storage/oracle_oci_storage.py
@@ -58,7 +58,7 @@ class OracleOCIStorage(BaseStorage):
try:
self.client.head_object(Bucket=self.bucket_name, Key=filename)
return True
- except:
+ except Exception:
return False
@override
diff --git a/api/providers/vdb/vdb-analyticdb/src/dify_vdb_analyticdb/analyticdb_vector_openapi.py b/api/providers/vdb/vdb-analyticdb/src/dify_vdb_analyticdb/analyticdb_vector_openapi.py
index f13d9c0817a..3df3295b2fc 100644
--- a/api/providers/vdb/vdb-analyticdb/src/dify_vdb_analyticdb/analyticdb_vector_openapi.py
+++ b/api/providers/vdb/vdb-analyticdb/src/dify_vdb_analyticdb/analyticdb_vector_openapi.py
@@ -66,7 +66,7 @@ class AnalyticdbVectorOpenAPI:
try:
from alibabacloud_gpdb20160503.client import Client # type: ignore
from alibabacloud_tea_openapi import models as open_api_models # type: ignore
- except:
+ except Exception:
raise ImportError(_import_err_msg)
self._collection_name = collection_name.lower()
self.config = config
diff --git a/api/providers/vdb/vdb-lindorm/src/dify_vdb_lindorm/lindorm_vector.py b/api/providers/vdb/vdb-lindorm/src/dify_vdb_lindorm/lindorm_vector.py
index d066aafff94..8c3292c6b1f 100644
--- a/api/providers/vdb/vdb-lindorm/src/dify_vdb_lindorm/lindorm_vector.py
+++ b/api/providers/vdb/vdb-lindorm/src/dify_vdb_lindorm/lindorm_vector.py
@@ -248,7 +248,7 @@ class LindormVectorStore(BaseVector):
params["routing"] = self._routing
self._client.get(index=self._collection_name, id=id, params=params)
return True
- except:
+ except Exception:
return False
@override
diff --git a/api/providers/vdb/vdb-opensearch/src/dify_vdb_opensearch/opensearch_vector.py b/api/providers/vdb/vdb-opensearch/src/dify_vdb_opensearch/opensearch_vector.py
index 07652eaebf8..c145e5479a2 100644
--- a/api/providers/vdb/vdb-opensearch/src/dify_vdb_opensearch/opensearch_vector.py
+++ b/api/providers/vdb/vdb-opensearch/src/dify_vdb_opensearch/opensearch_vector.py
@@ -191,7 +191,7 @@ class OpenSearchVector(BaseVector):
try:
self._client.get(index=self._collection_name.lower(), id=id)
return True
- except:
+ except Exception:
return False
@override
diff --git a/api/services/quota_service.py b/api/services/quota_service.py
index 9804e26e50e..1a17c1cb41d 100644
--- a/api/services/quota_service.py
+++ b/api/services/quota_service.py
@@ -20,7 +20,7 @@ class QuotaCharge:
try:
do_work()
charge.commit() # Confirm consumption
- except:
+ except Exception:
charge.refund() # Release frozen quota
If neither commit() nor refund() is called, the billing system's
diff --git a/api/services/trigger/webhook_service.py b/api/services/trigger/webhook_service.py
index 2e4f86c93c8..809693aa415 100644
--- a/api/services/trigger/webhook_service.py
+++ b/api/services/trigger/webhook_service.py
@@ -881,7 +881,7 @@ class WebhookService:
response_data = {"message": response_body}
else:
response_data = {"status": "success", "message": "Webhook processed successfully"}
- except:
+ except Exception:
response_data = {"message": response_body or "Webhook processed successfully"}
return response_data, status_code