Skip to content

fix(documents): preserve retry metadata until cleanup succeeds - #168

Merged
yuzushi-dev merged 2 commits into
mainfrom
fix/document-delete-surface-failures
Oct 1, 2026
Merged

yuzushi-dev merged 2 commits into
mainfrom
fix/document-delete-surface-failures

Conversation

@yuzushi-dev

Copy link
Copy Markdown
Owner

Document and folder deletion can currently report success after external cleanup fails, permanently losing the metadata needed to retry. This change preserves the PostgreSQL row until graph, vector and all generation source objects are removed, propagates cleanup errors, and prevents deletion while ingestion owns the document.

Graph cleanup and community stale marking run in one Neo4j transaction. Folder deletion stops on a failed document instead of silently deleting the folder.

Validation: 12 focused unit tests and 2 checks against disposable local Neo4j 5 pass; full-source Ruff lint, changed-file mypy and all five import contracts pass. The full unit suite has 1,052 passes, 4 skips and 2 environment failures reproduced on unmodified main (HEIF decoder and local Starlette version). No production deployment or cleanup is included.

@yuzushi-dev
yuzushi-dev marked this pull request as ready for review October 1, 2026 14:32
@yuzushi-dev
yuzushi-dev merged commit 6af98b7 into main Oct 1, 2026
5 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T14:35:00.425594Z a04670e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a04670e51e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +358 to +359
if document and document.processing_attempt_id:
raise DocumentDeletionConflict("Document is being processed; retry deletion later")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow deletion after a processing lease becomes stale

When a worker terminates after claiming a document, processing_attempt_id remains populated even though no processing is active. The stale-document recovery path in src/workers/recovery.py changes the document status and commits without clearing that field, so this unconditional check makes every subsequent delete return 409 forever; previously deletion was the user's escape hatch for such stuck documents. Clear stale ownership during recovery or only report a conflict when the processing lease is known to be live.

Useful? React with 👍 / 👎.

@yuzushi-dev
yuzushi-dev deleted the fix/document-delete-surface-failures branch October 2, 2026 07:36
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.

1 participant