Skip to content

Build and run agents you can see, understand and trust.

fix(rag): reject negative column indices when naming excel columns (#3874)

ChengFa749e6eab1b6f
diff --git a/src/agentscope/rag/_parser/_excel.py b/src/agentscope/rag/_parser/_excel.py
index d8b2d42d1..d8d703d6e 100644
--- a/src/agentscope/rag/_parser/_excel.py
+++ b/src/agentscope/rag/_parser/_excel.py
@@ -35,7 +35,15 @@ def _get_excel_column_name(col_index: int) -> str:
Returns:
`str`:
The corresponding Excel column letter(s).
+
+ Raises:
+ `ValueError`:
+ If ``col_index`` is negative.
"""
+ if col_index < 0:
+ raise ValueError(
+ f"Column index must be non-negative, got {col_index}.",
+ )
result = ""
col_index += 1
while col_index > 0: