#26839·strapi

Homepage should ignore stale permissions in draft/publish-only queries

Author: nclsndrCreated Jun 29, 2026Updated Sep 28, 2026
Labelsissue: bugsource: core:content-managerstatus: pending reproductionversion: 5stale

Homepage should ignore stale permissions in draft/publish-only queries

Node Version

v24.12.0

Package Manager

Yarn

Package Manager Version

4.12.0

Strapi Version

5.49.0 (fix/lint-warnings branch, PR #26818 context)

Operating System

macOS 26.5 (Darwin)

Database

SQLite (default examples/getstarted sandbox; bug is database-agnostic)

Javascript or Typescript

TypeScript

Reproduction URL

N/A - identified from code review and local source inspection.

Bug Description

The Content Manager homepage service should explicitly ignore stale permission subjects when building draft/publish-only recent document queries.

getContentTypesMeta now skips missing content types, but queryLastDocuments(..., true) still calls contentTypes.hasDraftAndPublish(strapi.contentType(uid)) for every permitted subject before that guard runs.

Current behavior is tolerant only because strapi.contentType(uid) returns undefined for a missing UID and contentTypes.hasDraftAndPublish(undefined) currently returns false. The homepage publish flow is therefore relying on helper tolerance rather than enforcing the invariant that stale permission subjects are dropped before content-type predicates run. There is also no focused test for stale UIDs in the draftAndPublishOnly=true path.

Affected package: @strapi/content-manager server homepage service.

Relevant code:

Steps to Reproduce

  1. Have an admin role with a stale plugin::content-manager.explorer.read permission subject whose UID no longer exists in strapi.contentTypes.
  2. Request the homepage recently published endpoint: GET /content-manager/homepage/recent-documents?action=publish.
  3. The service enters getRecentlyPublishedDocuments(), then queryLastDocuments(..., true).
  4. The stale UID is evaluated by contentTypes.hasDraftAndPublish(strapi.contentType(uid)) before the later getContentTypesMeta missing-content-type guard can skip it.

Expected Behavior

The homepage service should explicitly filter stale permission subjects before evaluating draft/publish metadata.

Missing content type UIDs should be ignored in both homepage recent document paths:

  • action=update / draftAndPublishOnly=false
  • action=publish / draftAndPublishOnly=true

Logs

N/A. Current code does not prove a live crash in this checkout because hasDraftAndPublish(undefined) returns false.

Code Snippets

Current risky path:

typescript
const allowedContentTypeUids = draftAndPublishOnly
  ? permittedContentTypes.filter((uid) => {
      return contentTypes.hasDraftAndPublish(strapi.contentType(uid));
    })
  : permittedContentTypes;

Recommended fix:

typescript
const allowedContentTypeUids = draftAndPublishOnly
  ? permittedContentTypes.filter((uid) => {
      const contentType = strapi.contentTypes[uid];
      return contentType !== undefined && contentTypes.hasDraftAndPublish(contentType);
    })
  : permittedContentTypes;

Add a focused homepage service test asserting a stale permission subject is ignored when draftAndPublishOnly === true and that the draft/publish predicate is not called with undefined.

Optionally, in getCountDocuments, use meta.contentType.collectionName instead of strapi.contentType(meta.uid).collectionName because meta is already built only from existing content types.

Media

N/A

Additional information

Existing homepage.test.ts covers stale UIDs for queryLastDocuments({ sort: 'updatedAt:desc' }), but not the publish-only path used by getRecentlyPublishedDocuments().

The original review comment says strapi.contentType(uid) throws for stale UIDs. Local source inspection shows it returns the registry lookup result, so the safer issue framing is: stale permission subjects are not explicitly filtered in the draft/publish-only flow, and the code lacks a regression test for that invariant.

Confirmation Checklist

  • I have checked the existing issues for duplicates. [NEEDS INPUT]
  • I agree to follow this project's Code of Conduct.