Skip to content

[BUG] Deleting a document in ingesting or processing status removes storage files despite returning 409 Conflict #341

Description

@mshkkkkk

Description
Attempting to delete a document with the ingesting or processing status returns 409 Conflict with a message instructing the user to pause it first. However, the request removes existing document files from storage before checking the document status.
The document and its page records remain in the database, and ingestion or processing continues with some of the required files already deleted.

Preconditions

  • The user is signed in and owns the document.
  • The document has the ingesting or processing status.
  • At least one page image has already been generated and saved to storage.

Steps to Reproduce

  1. Upload a multi-page document and start ingestion.
  2. Wait until page images appear in storage.
  3. While the document is still ingesting or processing, attempt to delete it.
  4. Inspect the response to DELETE /api/v1/documents/{id}.
  5. Check the document’s files in storage.
  6. Check the document and page records and observe whether processing continues.

Expected Result

  • The API returns 409 Conflict with the message:
    The document cannot be deleted while it is being ingested or processed. Pause it first.
  • The rejected deletion request does not remove any document files or database records.
  • Ingestion or processing continues normally with all required files available.

Actual Result

  • The API returns 409 Conflict with the expected message.
  • Existing document files are removed from storage despite the rejected deletion.
  • The document and page records remain in the database.
  • Ingestion or processing continues after the existing files have been removed.

Environment

  • Environment: http://98.90.162.1/
  • Endpoint: DELETE /api/v1/documents/{id}
  • Affected document statuses: ingesting, processing

Severity: High
Priority: Medium

Additional Information
This is a regression introduced after the original implementation of #77 — Delete a document.
The original implementation checked document ownership and status before deleting storage files. Commit 8670cf07, merged through PR #226 for TSA-136, moved storage cleanup before these checks.
As a result, files under uploads/{id}/ and pages/{id}/ are deleted before the API rejects the operation.

Screenshots:

chrome_pTzR76dYWT.mp4
Image Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingqa-reviewedVerified by QA

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions