Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: Handle NaN/Infinity values in ExeSQL JSON response (#12666)

E.G9da48ab0bd42
diff --git a/agent/tools/exesql.py b/agent/tools/exesql.py
index 012b00d84e..8f3f9dd175 100644
--- a/agent/tools/exesql.py
+++ b/agent/tools/exesql.py
@@ -86,6 +86,12 @@ class ExeSQL(ToolBase, ABC):
def convert_decimals(obj):
from decimal import Decimal
+ import math
+ if isinstance(obj, float):
+ # Handle NaN and Infinity which are not valid JSON values
+ if math.isnan(obj) or math.isinf(obj):
+ return None
+ return obj
if isinstance(obj, Decimal):
return float(obj) # 或 str(obj)
elif isinstance(obj, dict):