fix(knowledge): clear stale error_message on the remaining reprocess paths - #36
Draft
lyingbug wants to merge 2 commits into
Draft
fix(knowledge): clear stale error_message on the remaining reprocess paths#36lyingbug wants to merge 2 commits into
lyingbug wants to merge 2 commits into
Conversation
A knowledge item that failed once keeps error_message set; when it is reprocessed or driven through the finalizing pipeline, the stale message was never cleared, so the UI kept showing an outdated failure on items that were processing or had completed successfully. - SetFinalizing and FinalizeSubtask now clear error_message in the same atomic UPDATE that transitions parse_status - ProcessDocument clears knowledge.ErrorMessage when flipping the row to processing for a new attempt Add a SQLite-backed regression test covering both transitions.
cursor
Bot
force-pushed
the
cursor/clear-stale-error-message-followup-50d9
branch
from
August 3, 2026 11:52
f934870 to
cf2cb1d
Compare
…paths Follow-up to the error_message clearing added for SetFinalizing, FinalizeSubtask and ProcessDocument. Two routes still persisted a previous attempt's failure message: - ProcessManualUpdate flips a row back to 'processing' without clearing error_message. A manual knowledge item that failed earlier (for example when the knowledge base lookup failed, or after an Asynq retry) re-enters processing still carrying that message, so the UI shows a failure on a document it also shows as running. - finalizeIndexedKnowledgeState is the only route to 'completed' that bypasses FinalizeSubtask. When a document has no text chunks and no pending multimodal work it is completed in place, so the promotion that would otherwise clear the column never runs and a successfully indexed row keeps reporting the earlier failure. The 'processing' transition is extracted into markKnowledgeProcessing so ProcessDocument and ProcessManualUpdate share one definition of what starting a new attempt means, and a future worker cannot reintroduce the same omission. The helper also replaces the "processing" string literal with types.ParseStatusProcessing. Tests: markKnowledgeProcessing gets direct coverage, and the finalizeIndexedKnowledgeState table now seeds a stale error_message and asserts it survives the processing branches (FinalizeSubtask clears it later) and is cleared on the completed branch.
cursor
Bot
force-pushed
the
cursor/clear-stale-error-message-followup-50d9
branch
from
August 3, 2026 11:54
cf2cb1d to
e092f35
Compare
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.
Description
Follow-up to Tencent#2488, which cleared
error_messageinSetFinalizing,FinalizeSubtaskandProcessDocument. Reviewing the surrounding paths turned up two more places where a previous attempt's failure message is still persisted, both reachable without any of the transitions Tencent#2488 fixed:1.
ProcessManualUpdateflips a row back toprocessingwithout clearingerror_message.The entry guards skip
completed,deletingandcancelled, but deliberately notfailed. So a manual knowledge item that failed earlier — for example whenGetKnowledgeBaseByIDfailed and the handler wroteparse_status=failedplus a message, or when Asynq redelivers the task — re-entersprocessingstill carrying that message. The UI then shows a failure on a document it is simultaneously showing as running. This is the exact symptom Tencent#2488 fixed forProcessDocument, on the manual-knowledge sibling.2.
finalizeIndexedKnowledgeStateis the only route tocompletedthat bypassesFinalizeSubtask.When a document ends up with no text chunks and no pending multimodal work, it is completed in place rather than handed to the post-process pipeline, so the promotion that clears the column in Tencent#2488 never runs. Combined with (1), a manual item that failed once and is then reindexed into an empty result lands on
completedwith the old failure message still attached.processChunkspasses the same*types.Knowledgepointer through from the worker, so the stale in-memory value is what gets persisted.The
processingtransition is extracted intomarkKnowledgeProcessingsoProcessDocumentandProcessManualUpdateshare one definition of what starting a new attempt means, rather than having the clear applied at one call site and forgotten at the other. The helper also replaces the"processing"string literal withtypes.ParseStatusProcessing.Paths checked and deliberately not changed
processDocumentFromPassage— only ever called on a freshly created row (knowledge_create.go), whoseErrorMessageis empty by construction.moveOneKnowledge— rejects anything not alreadycompleted, so with fix(knowledge): clear stale error_message on reprocessing and finalize Tencent/WeKnora#2488 in place the column is clear before the move; only pre-fix(knowledge): clear stale error_message on reprocessing and finalize Tencent/WeKnora#2488 rows could carry a message here, which is a data-migration concern rather than a live bug.Type of Change
Related Issue
Follow-up to Tencent#2488. No separate issue.
Testing
TestMarkKnowledgeProcessingClearsPreviousAttemptError— new, covers the shared helper directly: afailedrow with a message must come outprocessingwith the column cleared.TestFinalizeIndexedKnowledgeState— extended: every case now seeds a staleerror_messageand asserts it is cleared on thecompletedbranch and left in place on theprocessingbranches, whereFinalizeSubtaskclears it on promotion.finalizeIndexedKnowledgeStateclear makesTestFinalizeIndexedKnowledgeState/empty_indexed_document_is_completed_without_summary_workfail withErrorMessage = "previous attempt failed", want ""; restoring it passes.go build ./internal/...— clean (needslibsqlite3-devfor thesqlite-veccgo bindings).go test ./internal/application/service/ ./internal/application/repository/ -count=1— both pass.go vet ./internal/application/service/— clean.gofmt -lon both changed files — clean;git diff --check— clean.Checklist
git diff --check origin/main...HEADpassesgolangci-lintrefuses to start in this environment withthe Go language version (go1.25) used to build golangci-lint is lower than the targeted Go version (1.26.0).go vetwas run instead and is clean.Screenshots / Recordings
Not applicable — no UI change. The user-visible effect is that an existing document card stops rendering a stale failure message; the frontend already reads
error_messageas-is.