Private Attribute Populate Validation#
Strapi v5 throws ValidationError: Invalid key <field> at <path> (HTTP 400) when a private attribute appears inside the populate tree that @strapi/utils's validatePopulate inspects. The error surfaces in the Content Manager and in any code path that calls strapi.documents(uid).findMany/findOne/⦠with a populate that the validator traverses into a nested component or relation context where the private field lives.
The Mismatch in a Nutshell#
Two subsystems produce the populate objects that validatePopulate later inspects:
| Subsystem | Where | What it includes |
|---|---|---|
Document Service repository (@strapi/core) | repository.ts L58ā63 | Only nonAttributesOperators in populateValidations.populate; no 'private' guard |
Content Manager (getPopulateForValidation) | populate.ts L208ā295 | Builds validation populate, explicitly skips private attributes |
The Document Service's validateParams calls validators.validatePopulate(ctx, params.populate, populateValidations) . The populateValidations object used there deliberately omits 'private' from the populate array , so private attributes in the top-level populate are not rejected by the Document Service itself. However, when defaultValidatePopulate is used instead (e.g. by the Content Manager controller or by plugins), it passes the full POPULATE_TRAVERSALS constant which does include 'private' , activating the throwPrivate traversal .
The result: the same nested populate object that the Document Service accepts without complaint will cause a 400 from any code path that calls defaultValidatePopulate instead.
throwPrivate Visitor#
throw-private.ts is a one-liner visitor registered in the traverseQueryPopulate pipeline:
if (attribute.private === true || isPrivateAttribute(schema, key)) {
throwInvalidKey({ key, path: path.attribute });
}
Any key the traverser encounters that resolves to a private attribute throws immediately. The traversal is recursive ā it descends into component and relation schemas ā so a private field three levels deep inside a component will still cause this error.
Trigger Conditions#
The bug manifests when all three of the following are true:
- A field is marked
private: true(either explicitly in the schema or viaisPrivateAttribute). - The field lives inside a component or relation that is populated in a query ā not at the root content-type level.
- The validate path includes the
'private'traversal (e.g. viadefaultValidatePopulateor the Content Manager's validation populate).
Reported combinations :
- Component field with both
required: trueandprivate: trueā accessing the Content Manager page returns 400. - Private field in a relation's target, explicitly requested via
populate: { relation: { fields: ['private_field'] } }inside a service. - Private field in a nested component reached via i18n's
localizationsrelation .
The error is asymmetric: requesting the same private field at the root of the owning content type (no nested populate) works fine, because validateFields in that context doesn't include 'privateFields' when called by the Document Service .
Content Manager Fix (PR #24101 ā merged 2026-05-22)#
PR #24101 fixed the Content Manager's own validation-populate builder (getPopulateForValidation) to skip private attributes before they ever reach validatePopulate. The guard is applied at two points:
- Scalar attributes:
getDoesAttributeRequireValidation(attribute) && !isPrivateAttribute(model, attributeName) - Media attributes: same dual condition
For components and dynamic zones the recursion calls getPopulateForValidation on the nested schema , which inherits the same private-attribute filter.
Regression coverage lives in validatable-fields-populate.test.ts under the componentWithPrivateRequiredFields test case, which asserts that only publicRequiredField appears in the output even when privateRequiredField is also required: true.
The fix applies only to the Content Manager's internal validation populate. It does not patch the Document Service's validatePopulate call path for external API or plugin callers.
Document Service Validation Config#
The Document Service validateParams builds a populateValidations object :
const populateValidations = {
sort: sortValidations, // ['nonAttributesOperators', 'dynamicZones', 'morphRelations']
field: fieldValidations, // ['scalarAttributes']
filters: filtersValidations, // ['nonAttributesOperators', 'dynamicZones', 'morphRelations']
populate: ['nonAttributesOperators'],
};
Private-field validation is intentionally excluded from sort, filters, fields, and populate in this config, meaning the Document Service itself does not throw on private attributes. The issue arises in code paths where a different caller (e.g., defaultValidatePopulate, the Content Manager controller, or a custom plugin) passes a populate that triggers the 'private' traversal.
Workarounds for Affected Versions#
Prior to the PR #24101 fix being released in your Strapi version :
- Remove
private: truefrom component fields that appear in required-population paths. Use access-control or sanitization middleware instead. - Use
populate: true(wildcard) instead of explicit field selection for the affected relation ā the wildcard path bypasses the key-level validator. - Register a middleware on the affected route that strips the private field from the response after fetching (workaround reported by users on 5.16.1+).
Key Files#
| File | Role |
|---|---|
packages/core/utils/src/validate/visitors/throw-private.ts | Visitor that throws on private attributes |
packages/core/utils/src/validate/validators.ts | validatePopulate, defaultValidatePopulate, traversal configuration |
packages/core/core/src/services/document-service/repository.ts | Document Service validateParams and populateValidations config |
packages/core/content-manager/server/src/services/utils/populate.ts | Content Manager getPopulateForValidation (fixed in PR #24101) |
packages/core/content-manager/server/src/services/utils/__tests__/validatable-fields-populate.test.ts | Regression tests for private-field exclusion |