fix: avoid stale knowledge on upload failure#1110
Open
Aphroq wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
描述 (Description)
修复
CreateKnowledgeFromFile在文件上传失败时仍提前保存 Knowledge 记录的问题。原来的执行顺序是:
这会导致当第 3 步失败时,数据库里已经留下带
file_hash的 Knowledge 记录;后续重新上传同一个文件时,会被重复校验拦住,无法继续处理。本 PR 将流程调整为:
knowledge.ID另外补充了回归测试,确保:
file_path变更类型 (Type of Change)
影响范围 (Scope)
测试 (Testing)
测试步骤 (Test Steps)
go test ./internal/application/service -run 'TestCreateKnowledgeFromFile_'TestCreateKnowledgeFromFile_DoesNotPersistWhenUploadFails通过,确认上传失败时数据库中不会残留 Knowledge 记录TestCreateKnowledgeFromFile_PersistsAfterSuccessfulUpload通过,确认上传成功后会正常保存 Knowledge 和文件路径检查清单 (Checklist)
相关 Issue
Fixes #1099
截图/录屏 (Screenshots/Recordings)
不涉及。
数据库迁移 (Database Migration)
配置变更 (Configuration Changes)
无。
部署说明 (Deployment Notes)
无特殊部署要求。
其他信息 (Additional Information)
本次修改主要涉及:
internal/application/service/knowledge.gointernal/application/service/knowledge_file_upload_test.go说明:
internal/application/service包全量测试在当前环境下仍有与本次修改无关的vectorstore/Elasticsearch 依赖失败;本 PR 相关回归测试已通过。