Skip to content

fix(knowledge): clear stale error_message on reprocessing and finalize - #2488

Merged
lyingbug merged 1 commit into
Tencent:mainfrom
oscarlius:pr/clear-stale-error-message
Aug 3, 2026
Merged

fix(knowledge): clear stale error_message on reprocessing and finalize#2488
lyingbug merged 1 commit into
Tencent:mainfrom
oscarlius:pr/clear-stale-error-message

Conversation

@oscarlius

Copy link
Copy Markdown
Contributor

Description

Once a knowledge item fails, error_message stays 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_message at exactly the transitions where a stale failure becomes misleading:

  • SetFinalizing — clears it in the same atomic UPDATE that flips parse_status to finalizing
  • FinalizeSubtask — clears it in the same atomic UPDATE that promotes finalizingcompleted (so a successfully promoted row can’t surface an error from a previous attempt)
  • ProcessDocument — clears knowledge.ErrorMessage when the row flips back to processing for a new attempt

Both repository transitions clear the column inside the same conditional UPDATE that guards on the current status, so the atomicity/race properties of the existing code are unchanged.

Type of Change

  • 🐛 Bug fix

Related Issue

N/A

Testing

  • New SQLite-backed regression test TestSetFinalizingAndFinalizeSubtask_ClearStaleErrorMessage: seeds a stale error_message, asserts SetFinalizing clears it, re-seeds, and asserts the FinalizeSubtask promotion clears it again.
  • go test ./internal/application/repository/ -count=1 — passes
  • gofmt -l on changed files — clean; git diff --check — passes
  • golangci-lint run --new-from-rev=upstream/main ./internal/... — 0 issues

Checklist

  • git diff --check origin/main...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes where applicable
  • Full-repository checks were run, or any unrelated/environment-dependent failures are documented above
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (method comment documents the clearing semantics)
  • Breaking changes are clearly called out in the description above

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.
@lyingbug
lyingbug merged commit 44206e4 into Tencent:main Aug 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants