Skip to content

fix(failed): reset on the Failed page puts OCR failures back in the q… - #446

Closed
fabgru wants to merge 1 commit into
admonstrator:nightlyfrom
fabgru:next-445-failed-reset-requeues-ocr
Closed

fabgru wants to merge 1 commit into
admonstrator:nightlyfrom
fabgru:next-445-failed-reset-requeues-ocr

Conversation

@fabgru

@fabgru fabgru commented Nov 23, 2026

Copy link
Copy Markdown

…ueue

Background
The Failed page says its documents are skipped until you reset them. Reset and Reset All only deleted the failed_documents entry and the processing_status row; the document's ocr_queue row stayed failed. The scheduled OCR drain and "Process All Pending" only take pending rows, the Failed page was empty afterwards, and the dashboard "Failed" card (which counts ocr_queue rows) kept counting the documents. The only way out was the "Process" button on each OCR queue row.

Changes

  • models/document.js: requeueFailedOcrQueueItems(documentIds) sets failed ocr_queue rows back to pending (processed_at cleared, ocr_text and wrote_back kept). Password-protected rows stay failed: they would only fail again until unlocked. resetAllFailedDocuments() does the same for its documents inside its transaction and returns { count, requeued }.
  • routes/queues.js: POST /api/failed/reset/:documentId and POST /api/failed/reset-all requeue and report requeued; the messages say when OCR will read documents again; the dashboard stats cache is invalidated when rows were requeued. @Swagger and OPENAPI/openapi.json updated.
  • resetFailedDocument() is deliberately unchanged: the other callers (OCR run finished, AI analysis after OCR, PDF unlock, manual, ignore) clear the entry as a result of success and must not touch the OCR queue.

Testing

  • tests/test-failed-reset-requeues-ocr.js (new, 5 cases: requeue and kept text, password-protected/done/pending/processing untouched, invalid IDs, resetFailedDocument leaves ocr_queue alone, reset-all scope). Without the model change 4 of 5 fail.
  • tests/test-failed-reset-all.js adapted to the new return shape.
  • ESLint, Prettier, typecheck clean on the changed files; the offline suite passes (three tests need Chrome or local sockets and only fail inside a sandbox; they pass outside it).

Impact
Failed page API only: one extra response field (requeued), no schema change. Databases already in the broken state (empty Failed page, failed OCR rows) are not repaired by this; they need a "retry failed" action on the OCR page.

Upstream Status
Not applicable (fork-only).

Fixes #445

…ueue

Background
The Failed page says its documents are skipped until you reset them. Reset
and Reset All only deleted the failed_documents entry and the
processing_status row; the document's ocr_queue row stayed `failed`. The
scheduled OCR drain and "Process All Pending" only take `pending` rows, the
Failed page was empty afterwards, and the dashboard "Failed" card (which
counts ocr_queue rows) kept counting the documents. The only way out was the
"Process" button on each OCR queue row.

Changes
- models/document.js: requeueFailedOcrQueueItems(documentIds) sets failed
  ocr_queue rows back to pending (processed_at cleared, ocr_text and
  wrote_back kept). Password-protected rows stay failed: they would only
  fail again until unlocked. resetAllFailedDocuments() does the same for its
  documents inside its transaction and returns { count, requeued }.
- routes/queues.js: POST /api/failed/reset/:documentId and
  POST /api/failed/reset-all requeue and report `requeued`; the messages say
  when OCR will read documents again; the dashboard stats cache is
  invalidated when rows were requeued. @Swagger and OPENAPI/openapi.json
  updated.
- resetFailedDocument() is deliberately unchanged: the other callers (OCR run
  finished, AI analysis after OCR, PDF unlock, manual, ignore) clear the entry
  as a result of success and must not touch the OCR queue.

Testing
- tests/test-failed-reset-requeues-ocr.js (new, 5 cases: requeue and kept
  text, password-protected/done/pending/processing untouched, invalid IDs,
  resetFailedDocument leaves ocr_queue alone, reset-all scope). Without the
  model change 4 of 5 fail.
- tests/test-failed-reset-all.js adapted to the new return shape.
- ESLint, Prettier, typecheck clean on the changed files; the offline suite
  passes (three tests need Chrome or local sockets and only fail inside a
  sandbox; they pass outside it).

Impact
Failed page API only: one extra response field (`requeued`), no schema
change. Databases already in the broken state (empty Failed page, failed
OCR rows) are not repaired by this; they need a "retry failed" action on the
OCR page.

Upstream Status
Not applicable (fork-only).

Fixes admonstrator#445

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@admonstrator
admonstrator deleted the branch admonstrator:nightly November 24, 2026 13:58
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