Skip to content

populateCreatorFields not working in Strapi v4 #12228

@vandrieu

Description

@vandrieu

Bug report

Describe the bug

Creator fields are not returned by Strapi V4 REST API even when populateCreatorFields is set to true.

Steps to reproduce the behavior

  1. Install Strapi v4
  2. Start the server using npm run develop
  3. Using Strapi admin panel, create a collection type with a name field
  4. Add an entry manually using the admin panel GUI
  5. Allow the collection to be queried through the public API (settings > roles and permissions > Public > add find and findOne on your collection and save)
  6. Query the data using the REST API
  7. Creator fields are not shown which is normal as per the V4 docs since populateCreatorFields is false by default: https://docs.strapi.io/developer-docs/latest/development/backend-customization/models.html#model-options
  8. Change the options in src/api/<collection>/content-types/<collection>/schema.json to the following:
{
  "kind": "collectionType",
  //...some configs
  "options": {
    "privateAttributes": ["name"],
    "populateCreatorFields": true
  },
  1. Make sure the server restarts or restart it
  2. Query the API again

Expected behavior

name field is not returned anymore
created_by field is returned

Actual behavior

name field is not returned anymore
created_by field is not returned

System

  • Node.js version: v14.18.2
  • NPM version: 6.14.13
  • Strapi version: 4.0.4
  • Database: sqlite
  • Operating system: MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundsource: core:strapiSource is core/strapi packagestatus: pending reproductionWaiting for free time to reproduce the issue, or more information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions