Skip to content

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

fix: prevent IndexError in PUT /api/v1/searches/<id> when search not found (#16027)

K.P8efa7383e683
diff --git a/api/apps/restful_apis/search_api.py b/api/apps/restful_apis/search_api.py
index aba4a0118b..66056af51b 100644
--- a/api/apps/restful_apis/search_api.py
+++ b/api/apps/restful_apis/search_api.py
@@ -144,11 +144,10 @@ async def update(search_id):
return get_json_result(data=False, message="no authorization", code=RetCode.AUTHENTICATION_ERROR)
try:
- search_apps = SearchService.query(tenant_id=current_user.id, id=search_id)
- if not search_apps:
- logging.warning("Search update target missing under caller tenant: search_id=%s tenant_id=%s", search_id, current_user.id)
+ search_results = SearchService.query(tenant_id=current_user.id, id=search_id)
+ if not search_results:
return get_json_result(data=False, message=f"Cannot find search {search_id}", code=RetCode.DATA_ERROR)
- search_app = search_apps[0]
+ search_app = search_results[0]
if req["name"].lower() != search_app.name.lower() and len(SearchService.query(name=req["name"], tenant_id=current_user.id, status=StatusEnum.VALID.value)) >= 1:
return get_data_error_result(message="Duplicated search name.")