#27789·strapi

Document Service rejects private attributes in nested populate `fields` ("Invalid key") — validator reads `includes.fields` but repository passes `field`

Author: geuryroustandCreated Sep 24, 2026Updated Sep 24, 2026
Labelsissue: bugseverity: lowstatus: pending reproductionsource: core:utilsversion: 5source: core:core

Node Version

22.17.1

Package Manager

yarn

Package Manager Version

1.22.22

Strapi Version

5.52.3

Operating System

Windows 11

Database

Strapi Cloud

Javascript or Typescript

Javascript

Reproduction URL

No response

Bug Description

Selecting a private: true attribute inside a nested populate via the Document Service throws ValidationError: Invalid key <attr> (400), while selecting the same attribute with top-level fields works.

This is a re-report of #23361, which was closed by the stale bot without a fix. The root cause is a key mismatch between @strapi/core and @strapi/utils:

@strapi/core/dist/services/document-service/repository.js passes the nested-populate validations under the key field (singular):

javascript
const populateValidations = {
  sort: sortValidations,
  field: fieldValidations,        // ['scalarAttributes']
  filters: filtersValidations,
  populate: ['nonAttributesOperators'],
};

But validatePopulate in @strapi/utils/dist/validate/validators.js reads includes.fields (plural) for nested fields:

javascript
if (key === 'fields') {
  set(key, await validateFields({ schema, getModel }, value, includes?.fields || FIELDS_TRAVERSALS));
}

includes.fields is always undefined, so it falls back to FIELDS_TRAVERSALS (scalarAttributes, privateFields, passwordFields). As a result, internal Document Service queries get the Content API's private-field restriction, but only for nested populate fields.

Per the docs, private only removes an attribute from server responses. It should not prevent backend code from reading the attribute through the Document Service.

Still present in 5.53.0, 5.54.0 and 5.55.0.

Steps to Reproduce

  1. Content type organization with an attribute marked private:
    json
    "status": { "type": "enumeration", "enum": ["active", "suspended"], "private": true }
  2. Content type organization-member with a relation organization → api::organization.organization.
  3. In backend code (service/controller/policy):
    javascript
    await strapi.documents('api::organization-member.organization-member').findFirst({
      populate: { organization: { fields: ['documentId', 'status'] } },
    });
    → throws ValidationError: Invalid key status (details: { key: 'status', path: 'status' }).
  4. For comparison, this works:
    javascript
    await strapi.documents('api::organization.organization').findFirst({
      fields: ['documentId', 'status'],
    });

Expected Behavior

Nested populate fields should be validated with the repository's field validations (scalarAttributes only), the same as top-level fields. Private attributes should be selectable by internal Document Service calls. Content API validation is unaffected, since it goes through defaultValidatePopulate.

Logs

bash
ValidationError: Invalid key status
    at Object.throwInvalidKey (@strapi/utils/dist/validate/utils.js:10:11)
    at visitor (@strapi/utils/dist/validate/visitors/throw-private.js:12:15)
    at traverse (@strapi/utils/dist/traverse/factory.js:68:19)
    at @strapi/utils/dist/traverse/query-fields.js:12:44
    at async @strapi/utils/dist/validate/validators.js:453:22

Code Snippets

Suggested one-line fix in @strapi/utils validatePopulate (we currently ship it as a patch-package patch):

diff
-            }, value, includes?.fields || FIELDS_TRAVERSALS));
+            }, value, includes?.fields || includes?.field || FIELDS_TRAVERSALS));

Alternatively, rename the key in @strapi/core's populateValidations from field to fields.

Media

No response

Additional information

Workaround: use strapi.db.query() (Query Engine) instead of the Document Service for these lookups, or apply the patch above.

Confirmation Checklist