fix(knowledge): clear stale error_message on reprocessing and finalize - #2488
Merged
Merged
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.
Draft
10 tasks
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
Once a knowledge item fails,
error_messagestays set on the row. When the item is later reprocessed or driven through the finalizing pipeline, nothing clears that column, so the UI keeps displaying an outdated failure message on items that are processing again or have already completed successfully.This PR clears
error_messageat exactly the transitions where a stale failure becomes misleading:SetFinalizing— clears it in the same atomicUPDATEthat flipsparse_statustofinalizingFinalizeSubtask— clears it in the same atomicUPDATEthat promotesfinalizing→completed(so a successfully promoted row can’t surface an error from a previous attempt)ProcessDocument— clearsknowledge.ErrorMessagewhen the row flips back toprocessingfor a new attemptBoth repository transitions clear the column inside the same conditional
UPDATEthat guards on the current status, so the atomicity/race properties of the existing code are unchanged.Type of Change
Related Issue
N/A
Testing
TestSetFinalizingAndFinalizeSubtask_ClearStaleErrorMessage: seeds a staleerror_message, assertsSetFinalizingclears it, re-seeds, and asserts theFinalizeSubtaskpromotion clears it again.go test ./internal/application/repository/ -count=1— passesgofmt -lon changed files — clean;git diff --check— passesgolangci-lint run --new-from-rev=upstream/main ./internal/...— 0 issuesChecklist
git diff --check origin/main...HEADpasses