Skip to content

🐛(backend) hide restore action for inherited deletion#2444

Open
ydnd wants to merge 1 commit into
suitenumerique:mainfrom
ydnd:fix-restore-deleted-child
Open

🐛(backend) hide restore action for inherited deletion#2444
ydnd wants to merge 1 commit into
suitenumerique:mainfrom
ydnd:fix-restore-deleted-child

Conversation

@ydnd

@ydnd ydnd commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Purpose

Fix #2127.

When a parent document is soft-deleted, child documents inherit the deleted state through ancestors_deleted_at. However, child documents still exposed the restore ability even when the child document itself was not directly deleted.

This could make the frontend show a restore action for a child document that cannot be restored independently.

Proposal

  • Expose the restore ability only when the document itself has deleted_at set.
  • Add a backend test covering the case where only an ancestor document is deleted.

External contributions

General requirements

Skip the checkbox below 👇 if you're fixing an issue or adding documentation

  • Before submitting a PR for a new feature I made sure to contact the product manager

CI requirements

  • I made sure that all existing tests are passing
  • I have signed off my commits with git commit --signoff (DCO compliance)
  • I have signed my commits with my SSH or GPG key (git commit -S)
  • My commit messages follow the required format: <gitmoji>(type) title description
  • I have added a changelog entry under ## [Unreleased] section (if noticeable change)

AI requirements

  • I used AI assistance to produce part or all of this contribution
  • I have read, reviewed, understood and can explain the code I am submitting
  • I can jump in a call or a chat to explain my work to a maintainer

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2efd947a-895f-4064-8403-4549b20df975

📥 Commits

Reviewing files that changed from the base of the PR and between 928bafe and ff991bf.

📒 Files selected for processing (2)
  • src/backend/core/models.py
  • src/backend/core/tests/documents/test_api_documents_restore.py

Walkthrough

In Document.get_abilities, the condition for the restore ability is tightened to require both that the user is the owner and that deleted_at is non-null on the document itself. Previously, ownership alone was sufficient. A new test case is added that creates a document with a soft-deleted parent, fetches the child document's detail endpoint as the owner, and asserts that abilities.restore is False.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • lunika
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: hiding the restore action for documents where only ancestors are deleted, which directly addresses the bug being fixed.
Description check ✅ Passed The description is related to the changeset, explaining the purpose, proposal, and the reasoning behind the fix for the restore ability.
Linked Issues check ✅ Passed The PR successfully addresses issue #2127 by fixing the restore ability to only show when a document itself is soft-deleted, preventing the 500 error scenario and providing the frontend flag needed.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the restore ability logic and adding corresponding test coverage, with no unrelated modifications present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Prevent child documents from exposing a restore ability when only an ancestor is deleted.

Signed-off-by: ydnd <1843212188@qq.com>
@ydnd ydnd force-pushed the fix-restore-deleted-child branch from 928bafe to ff991bf Compare June 22, 2026 09:15
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.

🐛 500 on restore endpoint

1 participant