Skip to content

fix(content-releases): deleting a non-localized entry leaves it in its releases - #28023

Merged
kibwashere merged 2 commits into
developfrom
fix/ee-254-delete-release-actions-non-localized
Oct 14, 2026
Merged

kibwashere merged 2 commits into
developfrom
fix/ee-254-delete-release-actions-non-localized

Conversation

@kibwashere

@kibwashere kibwashere commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

What does it do?

Atm, when you bulk delete an entry that is in a Release, then it persists in the UI of the Release - while it should disappear/make it empty. This PR is supposed to fix this.

Why is it needed?

Deleting entries of a non-localized content type with the bulk Delete action of the Content Manager list view leaves them in their releases: their release actions stay and point at documents that no longer exist. The release keeps counting them, and its status isn't recalculated (a release whose only entry was deleted stays Ready instead of Empty).

The list view sends the locale in the query string, while the bulkDelete controller reads it from the request body, so the delete reaches the release middleware without a locale. The middleware then filtered the actions on locale: undefined, which the query layer doesn't treat as IS NULL, so it matched none of them (non-localized actions are stored with locale: null). Any delete through the API or the Document Service without a locale has the same issue, for localized content types too.

Deleting from the edit view isn't affected: it sends locale=*, which the middleware already handled.

Ghost actions already in databases are left as they are: no migration. They're harmless on develop (publishing ignores a missing document) and can be removed from the release page.

How to test it?

I suggest you to create 2 apps to compare and test if the fix is working:

  • a regular one based on main
  • and a second one based on this PR fix

The setup

  1. Install the apps with an EE license
  2. Go in Settings > Releases: set a timezone.
  3. Go in Settings > Internationalization: add a second language.
  4. Go in Content Manager: open Tag (or any other content) and create three Tags (or three entries): Tag A and Tag B and Tag C. Save them as drafts.
  5. Go to Releases > New Release: name it Release 1, leave it unscheduled (untick the box), and create it.
  6. Go back to Content Manager > Tag: add the three tags to Release 1 (one by one).
  7. ✅ Go back to Releases > Release 1: it shows 3 entries ready

The bug #1 (🐛)

  1. Go back to Content Manager > Tag: select Tag B and Tag C (bulk select), and delete them together.
  2. ❌ Go back to Releases > Release 1: it still show 3 entries even (even after a refresh! that's the bug)
  3. Click publish..
    ^It is only possible to reproduce on the non-fix branch (cf. screenshot).
image

The bug #2 (🐞)

  1. Create a Tag D, add it alone to a new release Release 2 (status Ready).
  2. Bulk delete this `Tag D - so from the list view.
  3. Open Release 2 and refresh: 0 entries, status Empty
    ^On the fix branch, otherwise it keeps showing 1 entry + ready (cf. screenshot).
image

Note: a "regular" delete from the edit view is working well; the issue is only on the bulk delete side.

@kibwashere kibwashere added the needs-qa generates AI QA checklist label Oct 12, 2026
@kibwashere kibwashere changed the title fix(content-releases): deleting a non-localized entry leaves it in it… fix(content-releases): deleting a non-localized entry leaves it in its releases Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

AI-generated QA checklist

Scope / Impact

  • Server-side only, Content Releases (EE, cms-content-releases). packages/core/content-releases/server/src/middlewares/documents.ts — the deleteActionsOnDelete Document Service middleware now computes which release actions to remove via a new getDeletedLocalesFilter, instead of blindly forwarding ctx.params.locale.
  • The fixed bug: release actions for a non-localized content type are stored with locale: null, but the Content Manager still sends a locale on delete, so the old filter { contentType, entryDocumentId, locale: 'en' } matched nothing — the action survived the delete, the release kept counting a document that no longer exists, and updateReleaseStatus never ran (a release whose only entry was deleted stayed Ready instead of Empty).
  • New resolution rules (mirroring how the Document Service resolves locale on delete): non-localized CT or locale: '*' → no locale filter (all actions of the document); array → { locale: { $in: [...] } }; non-empty string → that locale; nothing/empty string → strapi.localization.getDefaultLocale().
  • Behavior change to watch: for a localized CT deleted without a locale, only the default locale's actions are now removed. Previously locale: undefined fell through as "no filter", which wiped actions for every locale. This affects programmatic strapi.documents(uid).delete({ documentId }), REST/GraphQL deletes, and any lifecycle code that omits locale.
  • Affected flows: entry delete and bulk delete in the Content Manager, Document Service / REST / GraphQL deletes, release action counts, release status recalculation, and the release publish flow. Applies to collection types and single types with Draft & Publish.
  • No migration — ghost actions already present in existing databases are intentionally left in place.
  • Also touched: new unit tests, new API integration tests (adds a localized-article fixture), and a contributor-doc paragraph in docs/docs/packages/core/content-releases/01-backend.md.

Manual QA

  • Non-localized entry (the reported bug): create two entries of a non-localized D&P content type, add both to a release, delete one from the edit view. The deleted entry's action disappears from the release, the entry count drops, and the other action is untouched.
  • Release status recalculation: put a single non-localized entry in a release, delete it, reload the release page — status becomes Empty, not Ready.
  • Bulk delete (explicitly named as broken in the PR description, and not covered by the added tests): select several non-localized entries in the list view, delete them in one action, confirm every corresponding release action is removed and the release status is recalculated.
  • Publish after delete: publish a release that previously contained a now-deleted entry — it completes with status done and no error about a missing document.
  • Localized entry, one locale (regression): add en and fr actions for the same document, delete only the fr locale from the CM → only the fr action is removed and the en action keeps its validity status.
  • Localized entry, all locales: delete with locale=* (or the "all locales" path in the UI) → every action for that document is removed.
  • Localized entry, no locale: strapi.documents('api::x.x').delete({ documentId }) with no locale → only the default locale's action is removed, other locales stay. Confirm this is the intended change and not a surprise for code that deletes programmatically.
  • Update path untouched (regression): editing an entry in a release still recalculates isEntryValid and the release status (updateActionsOnUpdate was not modified).
  • Non-EE / releases disabled: on a CE app (or EE without cms-content-releases), deleting entries still works normally with no errors in the server log.

Edge Cases

  • i18n plugin not installed: strapi.localization falls back to a no-provider service (isLocalizedContentType → false, getDefaultLocale → null). Delete an entry in a release on an app without i18n — all its actions are removed and nothing throws.
  • Empty-string locale (locale: '' in the query) resolves to the default locale rather than matching nothing.
  • Multiple locales at once (locale: ['en','fr']) produces the $in filter and removes exactly those two actions — verify on PostgreSQL / MySQL / SQLite, since this is a new query shape.
  • Default locale changed after the action was created — deleting without a locale targets the current default locale.
  • Entry in several releases: the same document in two or more unreleased releases — all of them lose the action and all get their status recalculated.
  • Already-published (Done) release containing the deleted entry: the release lookup in this path is not filtered on releasedAt: null, so a historical release can also lose actions and be re-evaluated. Confirm that is acceptable.
  • Eventual consistency: the cleanup is fire-and-forget (not awaited by the delete), so the release page may briefly show a stale count right after deleting — check that a refresh settles correctly and no UI state is permanently wrong.
  • Permissions / locale permissions: a user allowed to delete the entry but with restricted release or locale permissions still ends up with a consistent release.
  • Pre-existing ghost actions (no migration): on a DB that already has them, confirm the release page still renders, the ghost action can be removed manually, and publishing such a release does not fail.
  • Single types with Draft & Publish added to a release, then deleted/cleared.
  • Content type without Draft & Publish: middleware short-circuits before touching releases — no errors, no action deletion.

Test Setup

  • EE license with cms-content-releases enabled (STRAPI_LICENSE); RUN_EE=true for E2E. The added API tests are gated behind describeOnCondition(edition === 'EE').
  • i18n plugin with the default locale (en) plus a second locale (fr).
  • Content types with Draft & Publish: one non-localized (e.g. product) and one localized (the PR adds the api::localized-article.localized-article fixture to tests/api/plugins/content-releases/releases.test.api.ts).
  • At least one unreleased release holding actions on both content types.
  • Commands: yarn test:unit (new middlewares/__tests__/documents.test.ts), yarn test:api in EE mode, and ideally yarn test:api --db=postgres / --db=mysql for the $in filter.
  • Regenerate the test app (yarn test:generate-app) — the new fixture content type means a stale app produces misleading failures.

Possible QA Automation

Candidate Test Layer Priority Signal
getDeletedLocalesFilter resolution matrix (non-localized / * / array / string / none) Unit Recommended Already added in middlewares/__tests__/documents.test.ts — core of the fix
Delete removes release actions: non-localized, per-locale, default-locale API Integration Recommended Already added in releases.test.api.ts
Bulk delete (/content-manager/collection-types/:model/actions/bulkDelete) clears all matching actions API Integration Recommended Named as broken in the PR description but has no test; goes through deleteMany → per-document delete
Release status transitions (Ready → Empty / Blocked) after deleting its entries API Integration Recommended Tests assert action counts but not the recalculated status, which is half the reported bug
Delete with a locale array → $in filter against a real DB API Integration Optional New query shape; currently only covered by a mocked unit test
Delete with no i18n provider registered (strapi.localization fallback) Unit Optional Unit test mocks strapi.localization; the no-provider path is untested
Content Releases E2E: delete an entry that is in a release, release page shows the updated count/status E2E Optional Catches admin-side staleness from the fire-and-forget middleware
Single type in a release, then deleted API Integration Optional Middleware applies to single types too; untested

Assumptions / Gaps

  • The PR's "How to test it?" section is literally 1. wip... — all manual steps above are inferred from the diff and the "Why is it needed?" section, not author-provided.
  • Assumed the Content Manager sends a locale query param even for non-localized content types when i18n is installed; that is the premise of the reported bug but is not visible in the diff. Worth confirming whether the symptom also reproduces on an app without i18n.
  • The bulk-delete regression is claimed in the description but no test in this PR exercises the deleteMany path — confirm manually.
  • Unverified whether the admin release page auto-refreshes after a delete; since the cleanup is not awaited, a brief stale count may be expected rather than a bug.
  • Intentionally no migration for ghost actions already in users' databases — upgrade behavior for existing projects is out of scope here and should be sanity-checked separately.
  • Impact on an already-published release containing a deleted entry is not discussed in the PR.

QA Resolution

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

@trunk-io

trunk-io Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

@valfur03 valfur03 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.

Looks good to me! 🙌

@@ -82,7 +106,7 @@ const deleteActionsOnDelete: Middleware = async (ctx, next) => {
deleteActionsAndUpdateReleaseStatus({

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.

Heads up that this line, which existed before, is not awaited, so a crash inside could (maybe?) crash the whole process.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

true point! another open bug PR is solving it so I'll rebase as soon as it's merged 🫡

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.

I just thought again about this, it might not be awaited on purpose (to make the request resolve faster), but if that's the case, it could be worth to simply add a .catch(…). I didn't see the PR so I replied here 😅

@butcherZ butcherZ added qa-done Applied when a PR passes QA and removed needs-qa generates AI QA checklist labels Oct 13, 2026

@butcherZ butcherZ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

QAed manually, all good! thank you for taking care of this, great work :D

@butcherZ butcherZ added pr: fix This PR is fixing a bug source: core:content-releases Source is the Content Releases feature labels Oct 13, 2026
@kibwashere
kibwashere force-pushed the fix/ee-254-delete-release-actions-non-localized branch from bd09d64 to 286f1d0 Compare October 13, 2026 15:39
@github-actions github-actions Bot removed the qa-done Applied when a PR passes QA label Oct 13, 2026
@kibwashere kibwashere added the qa-done Applied when a PR passes QA label Oct 13, 2026
@kibwashere kibwashere added this to the 5.58.1 milestone Oct 13, 2026
@kibwashere
kibwashere force-pushed the fix/ee-254-delete-release-actions-non-localized branch from 286f1d0 to d98432a Compare October 14, 2026 12:32
@github-actions github-actions Bot removed the qa-done Applied when a PR passes QA label Oct 14, 2026
@kibwashere
kibwashere merged commit 5263c1c into develop Oct 14, 2026
137 checks passed
@kibwashere
kibwashere deleted the fix/ee-254-delete-release-actions-non-localized branch October 14, 2026 13:31
innerdvations added a commit to irontaek/strapi that referenced this pull request Oct 15, 2026
Keep the locale filter from strapi#28023 and await release-action cleanup so
status failures are logged instead of becoming unhandled rejections.
@draft-release draft-release Bot mentioned this pull request Oct 19, 2026
nclsndr added a commit that referenced this pull request Nov 4, 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 added a commit that referenced this pull request 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 added a commit that referenced this pull request Nov 6, 2026
…28169)

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.
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 source: core:content-releases Source is the Content Releases feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants