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

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

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

Signed-off-by: ydnd <1843212188@qq.com>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the core fix: preventing restore actions from appearing for child documents when only ancestors are deleted, directly addressing the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly explains the bug being fixed: child documents incorrectly expose a restore ability when only an ancestor is deleted, not the document itself.

✏️ 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.

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