Go: add context, part11 (#17426)

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-07-27 17:48:44 +08:00
committed by GitHub
parent 30b40caff8
commit 19d861b797
28 changed files with 111 additions and 89 deletions

View File

@@ -209,7 +209,7 @@ async def parse(tenant_id, dataset_id):
not_found.append(id)
continue
if not doc:
return get_error_data_result(message=f"You don't own the document {id}.")
return get_error_data_result(message=f"you don't own the document {id}")
info = {"run": "1", "progress": 0, "progress_msg": "", "chunk_num": 0, "token_num": 0}
if (
DocumentService.filter_update(
@@ -274,7 +274,7 @@ async def stop_parsing(tenant_id, dataset_id):
for id in doc_list:
doc = DocumentService.query(id=id, kb_id=dataset_id)
if not doc:
return get_error_data_result(message=f"You don't own the document {id}.")
return get_error_data_result(message=f"you don't own the document {id}")
if doc[0].run != TaskStatus.RUNNING.value:
return construct_json_result(
code=RetCode.DATA_ERROR,
@@ -449,7 +449,7 @@ async def list_chunks(tenant_id, dataset_id, document_id):
return get_error_data_result(message=f"You don't own the dataset {dataset_id}.")
doc = DocumentService.query(id=document_id, kb_id=dataset_id)
if not doc:
return get_error_data_result(message=f"You don't own the document {document_id}.")
return get_error_data_result(message=f"you don't own the document {document_id}")
doc = doc[0]
req = request.args
page = int(req.get("page", 1))
@@ -537,7 +537,7 @@ async def get_chunk(tenant_id, dataset_id, document_id, chunk_id):
return get_error_data_result(message=f"You don't own the dataset {dataset_id}.")
doc = DocumentService.query(id=document_id, kb_id=dataset_id)
if not doc:
return get_error_data_result(message=f"You don't own the document {document_id}.")
return get_error_data_result(message=f"you don't own the document {document_id}")
try:
chunk = settings.docStoreConn.get(chunk_id, search.index_name(dataset_tenant_id), [dataset_id])
if chunk is None or str(chunk.get("doc_id", chunk.get("document_id"))) != str(document_id):
@@ -588,7 +588,7 @@ async def get_document_structure_graph(tenant_id, dataset_id, document_id):
return get_error_data_result(message=f"You don't own the dataset {dataset_id}.")
docs = DocumentService.query(id=document_id, kb_id=dataset_id)
if not docs:
return get_error_data_result(message=f"You don't own the document {document_id}.")
return get_error_data_result(message=f"you don't own the document {document_id}")
# Resolve the doc's configured template group → child template ids
# so we can render tabs in the order the user picked them.
@@ -902,7 +902,7 @@ async def delete_document_structure_graph(tenant_id, dataset_id, document_id):
return get_error_data_result(message=f"You don't own the dataset {dataset_id}.")
docs = DocumentService.query(id=document_id, kb_id=dataset_id)
if not docs:
return get_error_data_result(message=f"You don't own the document {document_id}.")
return get_error_data_result(message=f"you don't own the document {document_id}")
req = await get_request_json()
template_id = str(req.get("template_id") or "").strip()
@@ -948,7 +948,7 @@ async def add_chunk(tenant_id, dataset_id, document_id):
return get_error_data_result(message=f"You don't own the dataset {dataset_id}.")
doc = DocumentService.query(id=document_id, kb_id=dataset_id)
if not doc:
return get_error_data_result(message=f"You don't own the document {document_id}.")
return get_error_data_result(message=f"you don't own the document {document_id}")
doc = doc[0]
req = await get_request_json()
if is_content_empty(req.get("content")):
@@ -1037,7 +1037,7 @@ async def rm_chunk(tenant_id, dataset_id, document_id):
return get_error_data_result(message=f"You don't own the dataset {dataset_id}.")
docs = DocumentService.query(id=document_id, kb_id=dataset_id)
if not docs:
return get_error_data_result(message=f"You don't own the document {document_id}.")
return get_error_data_result(message=f"you don't own the document {document_id}")
req = await get_request_json()
if not req:
return get_result()
@@ -1091,7 +1091,7 @@ async def update_chunk(tenant_id, dataset_id, document_id, chunk_id):
return get_error_data_result(message=f"You don't own the dataset {dataset_id}.")
doc = DocumentService.query(id=document_id, kb_id=dataset_id)
if not doc:
return get_error_data_result(message=f"You don't own the document {document_id}.")
return get_error_data_result(message=f"you don't own the document {document_id}")
doc = doc[0]
chunk = settings.docStoreConn.get(chunk_id, search.index_name(dataset_tenant_id), [dataset_id])
if chunk is None or str(chunk.get("doc_id", chunk.get("document_id"))) != str(document_id):

View File

@@ -882,10 +882,10 @@ def _get_docs_with_request(req, dataset_id: str):
doc_id = q.get("id")
if doc_id:
if not DocumentService.query(id=doc_id, kb_id=dataset_id):
return RetCode.DATA_ERROR, f"You don't own the document {doc_id}.", [], 0
return RetCode.DATA_ERROR, f"you don't own the document {doc_id}", [], 0
doc_ids_filter = [doc_id] # id provided, ignore other filters
if doc_name and not DocumentService.query(name=doc_name, kb_id=dataset_id):
return RetCode.DATA_ERROR, f"You don't own the document {doc_name}.", [], 0
return RetCode.DATA_ERROR, f"you don't own the document {doc_name}", [], 0
doc_ids = q.getlist("ids")
if doc_id and len(doc_ids) > 0: