Skip to content

fix(content-releases): deleting an entry rewrites published releases - #28169

Merged
nclsndr merged 1 commit into
developfrom
fix/releases-delete-rewrites-published
Nov 6, 2026
Merged

nclsndr merged 1 commit into
developfrom
fix/releases-delete-rewrites-published

Conversation

@nclsndr

@nclsndr nclsndr commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

What does it do?

Deleting an entry no longer changes releases that are already published. The release lookup and the action delete now only target releases with releasedAt: null, in the Document Service middleware and in the lifecycle hook.

Pending releases keep the current behaviour: the actions of the deleted entry are removed and the release status is computed again.

Why is it needed?

A published release is the record of what was published. Deleting an entry removed its actions from every release, published or not, and computed their status again. A done release could become empty or ready.

#28023 extended the action filter to every non-localized content type, so this now happens on all content types with Draft & Publish. Localized content types already had the problem in 5.58.0.

How to test it?

EE, with content releases enabled.

  1. Create a non-localized content type with Draft & Publish, then create an entry.
  2. Add the entry to a release and publish the release. The release status is done.
  3. Delete the entry.
  4. Open the release. Its status is still done.
  5. Do the same with a pending release. The action of the deleted entry is removed, as before.

Automated: yarn test:unit server/src/middlewares in packages/core/content-releases.

Related issue(s)/PR(s)


AI assisted

@nclsndr nclsndr added pr: fix This PR is fixing a bug source: core:content-releases Source is the Content Releases feature labels Oct 21, 2026
@nclsndr nclsndr self-assigned this Oct 21, 2026
@nclsndr nclsndr added the needs-qa generates AI QA checklist label Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI-generated QA checklist

Scope / Impact

EE only (cms-content-releases feature). Backend-only, 4 files, +37/-6; no admin/UI code touched.

Release-action cleanup on entry delete is now scoped to unreleased releases only (releasedAt: null), at two call sites that previously mutated every release containing the entry:

  • server/src/middlewares/documents.ts — deleteActionsOnDelete. The Document Service delete path (Content Manager delete, strapi.documents().delete(), bulk delete).
  • server/src/bootstrap.ts — the afterDeleteMany DB lifecycle. The non-Document-Service path, notably deleting an i18n locale.

Each now filters the release findMany with releasedAt: null and adds release: { releasedAt: null } to the action deleteMany.

Three things drive the risk:

  1. Root cause: updateReleaseStatus (services/release.ts:460) unconditionally overwrites status to empty/ready/blocked — it has no done branch. A done release that lost its last action was rewritten to empty.
  2. New state: published releases now keep actions pointing at deleted entries. release-action.ts findPage tolerates a missing entry (entry ? ... : null), but the UI rendering a null entry is newly reachable.
  3. New SQL shape: a relation predicate on deleteMany pushes the query through the join/subquery path in @strapi/database (query-builder.ts shouldUseSubQuery/runSubQuery, plus qualifyRootColumns to disambiguate locale/id). Different statement than before, and dialect-sensitive.

Manual QA

  • Published release untouched, non-localized (the fix(content-releases): deleting a non-localized entry leaves it in its releases #28023 regression): non-localized D&P type → entry → add to release → publish (done) → delete the entry → release still done and still lists the action.
  • Published release untouched, localized (the 5.58.0 case): i18n D&P type, entry in two locales, both in a published release. Delete one locale → the done release keeps both actions and its status.
  • Pending release still cleans up (must not regress): entry in an unpublished release → delete → action gone, status recomputed (empty if it was the only one, else ready/blocked).
  • Mixed: same entry in a published and a pending release. One delete → pending loses the action and recomputes, published keeps it. Highest-value check — it exercises the deleteMany relation filter, not just the findMany one.
  • Published-release detail page with a deleted entry: renders without error, deleted row shows a placeholder/null status, and grouping (content type / locale / action type) and pagination still work.
  • Locale deletion (bootstrap.ts lifecycle, not the middleware): localized entries in one published + one pending release → delete the locale in Settings → i18n. Published keeps actions and done; pending is cleaned.
  • No silent failure: cleanup is wrapped in try/catch and only logs. Watch for Error while deleting release actions after delete / ...after entry deleteMany — a malformed join surfaces there, not in the UI.
  • yarn test:unit server/src/middlewares in packages/core/content-releases, then the package's full yarn test:unit.

Edge Cases

  • failed release: publish failure sets status: 'failed' but leaves releasedAt null (release.ts:392 vs :368-369), so entry delete still strips its actions and may recompute it to empty. Confirm that is intended — the PR description doesn't say.
  • Scheduled release (scheduledAt set, releasedAt null): still treated as pending and cleaned; confirm the scheduled job doesn't newly fail with "No entries to publish".
  • Dialects: run the mixed published/pending delete on SQLite, PostgreSQL, and MySQL (DB=postgres|mysql yarn develop). MySQL in particular can't delete from a table it selects from without the nested-subquery wrapper.
  • Non-D&P content type: hasDraftAndPublish early-return — deleting such an entry still touches no release.
  • locale: '*' and array locale deletes: getDeletedLocalesFilter widens to all locales / $in; confirm the releasedAt filter still wins.
  • Bulk delete from the Content Manager list view, with some entries in published releases.
  • Unpublish actions: a published release holding a type: 'unpublish' action for a deleted entry is preserved too.
  • Permissions: a role without content-releases access sees no change, and entry delete still succeeds when the cleanup is a no-op.

Test Setup

  • Enterprise license with cms-content-releases — none of this is reachable in CE.
  • One non-localized D&P collection type, one i18n-enabled D&P collection type, optionally one without D&P as a negative control.
  • At least two locales (en default + fr).
  • Releases: one published (done), one pending, one scheduled, ideally one failed; plus one entry deliberately in both a published and a pending release.
  • SQLite for the functional pass; PostgreSQL + MySQL via docker-compose -f docker-compose.dev.yml up -d for the join-delete check.
  • Sandbox: examples/getstarted.

Possible QA Automation

Candidate Test Layer Priority Signal
bootstrap.ts afterDeleteMany filters released releases Unit Recommended The middleware got a dedicated test; the identical lifecycle change has none, yet it owns the locale-deletion path.
Entry in published + pending release → only the pending one is mutated API Integration Recommended The unit test asserts the where object shape, not that the SQL deletes the right rows.
Same scenario on PostgreSQL and MySQL API Integration Recommended yarn test:api --db=postgres / --db=mysql; the join/subquery delete is dialect-specific.
Release detail page renders an action whose entry was deleted E2E (content-releases, RUN_EE=true) Recommended Orphaned actions in published releases are newly reachable; findPage returns entry: null.
Locale deletion preserves published-release actions API Integration Optional Covers the bootstrap.ts branch end-to-end, including the where.locale ?? null fallback.
failed release behaviour on entry delete Unit Optional Pins whichever semantics the team settles on for releasedAt: null, status: 'failed'.
updateReleaseStatus never yields done Unit Optional Documents the root cause so another caller doesn't reintroduce it.

Assumptions / Gaps

  • Migrations still rewrite published releases. server/src/migrations/index.ts (deleteActionsOnDeleteContentType, deleteActionsOnDisableDraftAndPublish, disableContentTypeLocalized) deletes actions by contentType with no releasedAt filter, so deleting a content type or turning off D&P/i18n still empties and recomputes a done release. The PR deliberately scopes itself to entry delete and words the doc change accordingly — but under the stated principle these are the same class of bug. Worth confirming with the author that it's intentional.
  • failed releases aren't addressed in the description; treated above as pending since releasedAt is null.
  • Orphan growth is unbounded: nothing prunes actions in published releases whose entries are gone, so strapi_release_actions keeps rows for deleted documents indefinitely. Implied by the fix, but no compaction story is described.
  • No UI spec for the deleted-entry row (label, badge, link target). The backend returns entry: null / status: null; the admin side was not changed here and should be eyeballed.
  • The diff was analysed statically — the suggested commands were not run locally.

QA Resolution

Add qa-done when completed, or qa-skipped if intentionally skipped.

@nclsndr
nclsndr force-pushed the fix/releases-delete-rewrites-published branch from 2b5a5ad to 9a2dbed Compare November 4, 2026 13:47

@giu1io giu1io left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

QA passed. I tested the PR as it is at 9a2dbed, comparing it with its parent be7c553, on EE with SQLite, Postgres and MySQL, and on CE. All 12 scenarios ran.

The fix

  • Deleting a non-localized entry that a published release contains leaves that release done, with its action and releasedAt untouched. On the parent, the same delete turned it into empty with 0 actions.
  • The same holds for a Content API delete, a bulk delete from the Content Manager, deleting one locale of a localized entry (the other locale's action stays too), and deleting a locale from the i18n settings.
  • Postgres and MySQL behave the same as SQLite for the entry delete and the locale delete.

Unchanged

  • Pending releases still lose the deleted entry's action and get their status recomputed (ready with one fewer entry, or empty), and other entries' actions are kept.
  • Making an entry invalid still marks its pending release blocked, and the published release stays done.
  • On CE the delete works and the releases routes aren't mounted. No error is logged in any scenario.

Non-blocking:

  • A done release now keeps the action of an entry that no longer exists, and the release details page shows that row as undefined, with no action menu. On develop the action was deleted instead, and the release lost its done status, which is worse. The page's handling of a missing entry (ReleaseDetailsPage.tsx:623) predates this PR.
  • A release in failed status is still treated as pending: deleting its entry removes the action and the status goes from failed to empty. I'm not sure whether that's intended; the doc doesn't say.
  • The tests check the where objects of mocked queries. An API test with an entry in both a published and a pending release would cover the real behaviour across databases.
  • docs/docs/packages/core/content-releases/01-backend.md:238 still says "all releases" are recalculated.

AI Assisted Comment

@giu1io giu1io added qa-done Applied when a PR passes QA and removed needs-qa generates AI QA checklist labels Nov 6, 2026
Deleting an entry removed its actions from every release, including
released ones, then recomputed their status. A done release could turn
empty or ready. #28023 widened this to every non-localized type.

Scope the release lookup and the action delete to releases with
releasedAt null, in the document middleware and the lifecycle hook.
@nclsndr
nclsndr force-pushed the fix/releases-delete-rewrites-published branch from 9a2dbed to 697985a Compare November 6, 2026 10:40
@nclsndr

nclsndr commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on develop (24h rule), no change to the fix; no conflicts.

@github-actions github-actions Bot removed the qa-done Applied when a PR passes QA label Nov 6, 2026
@nclsndr nclsndr added the qa-done Applied when a PR passes QA label Nov 6, 2026
@nclsndr
nclsndr merged commit 2955b24 into develop Nov 6, 2026
153 checks passed
@nclsndr
nclsndr deleted the fix/releases-delete-rewrites-published branch November 6, 2026 11:37
butcherZ added a commit that referenced this pull request Nov 6, 2026
Conflicts:
- package.json files: keep design system 2.3.0-alpha.1 from the feature branch, take the 5.61.0 release versions from develop.
- yarn.lock: feature lock reconciled with yarn install; develop's graphql-tools/utils and whatwg-node/promise-helpers resolutions kept.
- database errors: export both SavepointError and InvalidBooleanError.
- content-releases bootstrap and documents middleware: keep the feature's deletePlannedActions, which already limits entry deletes to releases that haven't run (#28169's intent); its test now asserts that filter.
- content-releases backend docs: keep the feature wording, which already covers released releases keeping their actions.
butcherZ added a commit that referenced this pull request Nov 9, 2026
Conflicts:
- package.json files: keep design system 2.3.0-alpha.1 from the feature branch, take the 5.61.0 release versions from develop.
- yarn.lock: feature lock reconciled with yarn install; develop's graphql-tools/utils and whatwg-node/promise-helpers resolutions kept.
- database errors: export both SavepointError and InvalidBooleanError.
- content-releases bootstrap and documents middleware: keep the feature's deletePlannedActions, which already limits entry deletes to releases that haven't run (#28169's intent); its test now asserts that filter.
- content-releases backend docs: keep the feature wording, which already covers released releases keeping their actions.
@draft-release draft-release Bot added this to the 5.62.0 milestone Nov 10, 2026
@draft-release draft-release Bot mentioned this pull request Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: fix This PR is fixing a bug qa-done Applied when a PR passes QA source: core:content-releases Source is the Content Releases feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants