Go: fix warnings (#17738)

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-08-03 21:30:01 +08:00
committed by GitHub
parent d357eea8ef
commit 86021932ae
103 changed files with 437 additions and 439 deletions

View File

@@ -2572,7 +2572,7 @@ async def _stream_agent_attachment(tenant_id, attachment_id, *, inline: bool):
content_type, ext, filename = _attachment_request_metadata()
data = await thread_pool_exec(settings.STORAGE_IMPL.get, tenant_id, attachment_id)
if not data:
return get_data_error_result(message="Document not found!")
return get_data_error_result(message="document not found")
response = await make_response(data)
if inline:
apply_preview_file_response_headers(response, content_type, ext, filename)

View File

@@ -1199,9 +1199,9 @@ async def switch_chunks(tenant_id, dataset_id, document_id):
def _switch_sync():
e, doc = DocumentService.get_by_id(document_id)
if not e:
return get_error_data_result(message="Document not found!")
return get_error_data_result(message="document not found")
if not doc or str(doc.kb_id) != str(dataset_id):
return get_error_data_result(message="Document not found!")
return get_error_data_result(message="document not found")
for cid in req["chunk_ids"]:
if not settings.docStoreConn.update(
{"id": cid},

View File

@@ -1253,7 +1253,7 @@ async def update_metadata_config(tenant_id, dataset_id, document_id):
try:
e, doc = DocumentService.get_by_id(doc.id)
if not e:
return get_data_error_result(message="Document not found!")
return get_data_error_result(message="document not found")
except Exception as e:
return get_json_result(code=RetCode.EXCEPTION_ERROR, message=repr(e))
@@ -1462,7 +1462,7 @@ def _run_sync(user_id: str, req):
return RetCode.DATA_ERROR, "Tenant not found!"
e, doc = DocumentService.get_by_id(doc_id)
if not e:
return RetCode.DATA_ERROR, "Document not found!"
return RetCode.DATA_ERROR, "document not found"
if str(req["run"]) == TaskStatus.CANCEL.value:
tasks = list(TaskService.query(doc_id=doc_id))
@@ -1904,7 +1904,7 @@ async def get_artifact(filename):
return get_data_error_result(message="Invalid filename.")
ext = os.path.splitext(basename)[1].lower()
if ext not in ARTIFACT_CONTENT_TYPES:
return get_data_error_result(message="Invalid file type.")
return get_data_error_result(message="invalid file type")
session_id = request.args.get("session_id", "")
if not await thread_pool_exec(_sandbox_artifact_accessible, basename, current_user.id) and not await thread_pool_exec(_sandbox_artifact_session_accessible, session_id, current_user.id):
return get_data_error_result(message="Artifact not found.")
@@ -2054,11 +2054,11 @@ async def get(doc_id):
"""
try:
if not DocumentService.accessible(doc_id, current_user.id):
return get_data_error_result(message="Document not found!")
return get_data_error_result(message="document not found")
e, doc = DocumentService.get_by_id(doc_id)
if not e:
return get_data_error_result(message="Document not found!")
return get_data_error_result(message="document not found")
b, n = File2DocumentService.get_storage_address(doc_id=doc_id)
data = await thread_pool_exec(settings.STORAGE_IMPL.get, b, n)
@@ -2128,9 +2128,9 @@ async def download(dataset_id, document_id):
if not document_id:
return get_error_data_result(message="Specify document_id please.")
if not KnowledgebaseService.accessible(kb_id=dataset_id, user_id=current_user.id):
return get_data_error_result(message="Document not found!")
return get_data_error_result(message="document not found")
if not DocumentService.accessible(document_id, current_user.id):
return get_data_error_result(message="Document not found!")
return get_data_error_result(message="document not found")
doc = DocumentService.query(kb_id=dataset_id, id=document_id)
if not doc:
return get_error_data_result(message=f"The dataset not own the document {document_id}.")
@@ -2190,7 +2190,7 @@ async def download_document(document_id):
if not document_id:
return get_error_data_result(message="Specify document_id please.")
if not DocumentService.accessible(document_id, current_user.id):
return get_data_error_result(message="Document not found!")
return get_data_error_result(message="document not found")
doc = DocumentService.query(id=document_id)
if not doc:
return get_error_data_result(message=f"The dataset not own the document {document_id}.")

View File

@@ -126,7 +126,7 @@ def reset_document_for_reparse(doc, tenant_id, parser_id=None, pipeline_id=None)
# Update document
e = DocumentService.update_by_id(doc.id, update_fields)
if not e:
return get_error_data_result(message="Document not found!")
return get_error_data_result(message="document not found")
# Update document statistics before deleting all document rows. Pipeline
# compilation rows may exist even when token_num is zero, so the doc-store
@@ -141,9 +141,9 @@ def reset_document_for_reparse(doc, tenant_id, parser_id=None, pipeline_id=None)
doc.process_duration * -1,
)
except LookupError:
return get_error_data_result(message="Document not found!")
return get_error_data_result(message="document not found")
if not e:
return get_error_data_result(message="Document not found!")
return get_error_data_result(message="document not found")
settings.docStoreConn.delete({"doc_id": doc.id}, search.index_name(tenant_id), doc.kb_id)
# Delete chunk images

View File

@@ -601,7 +601,7 @@ def get_file_content(uid: str, file_id: str):
"""
e, file = FileService.get_by_id(file_id)
if not e:
return False, "Document not found!"
return False, "document not found"
if not check_file_team_permission(file, uid):
return False, "no authorization"
return True, file

View File

@@ -684,7 +684,7 @@ class FileService(CommonService):
try:
e, doc = DocumentService.get_by_id(doc_id)
if not e:
raise Exception("Document not found!")
raise Exception("document not found")
tenant_id = DocumentService.get_tenant_id(doc_id)
if not tenant_id:
raise Exception("Tenant not found!")

View File

@@ -1103,16 +1103,16 @@ def validate_immutable_fields(update_doc_req: UpdateDocumentReq, doc):
or (None, None) if validation passes.
"""
if update_doc_req.chunk_count is not None and update_doc_req.chunk_count != int(getattr(doc, "chunk_num", -1)):
return "Can't change `chunk_count`.", RetCode.DATA_ERROR
return "can't change `chunk_count`", RetCode.DATA_ERROR
if update_doc_req.token_count is not None and update_doc_req.token_count != int(getattr(doc, "token_num", -1)):
return "Can't change `token_count`.", RetCode.DATA_ERROR
return "can't change `token_count`", RetCode.DATA_ERROR
if update_doc_req.progress is not None:
progress_from_db = float(getattr(doc, "progress", -1.0))
# should not use "==" to compare two float values
if not math.isclose(update_doc_req.progress, progress_from_db):
return "Can't change `progress`.", RetCode.DATA_ERROR
return "can't change `progress`", RetCode.DATA_ERROR
return None, None