-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Labels
issue: discussionA general discussion issueA general discussion issueseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solveIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: core:strapiSource is core/strapi packageSource is core/strapi packagestalestale-before-2023status: confirmedConfirmed by a Strapi Team member or multiple community membersConfirmed by a Strapi Team member or multiple community members
Description
Bug report
Required System information
- Node.js version: 16.16.0
- Yarn version: 1.22.19
- Strapi version: 4.3.9
- Database: Postgres:12.0
- Operating system: node:16 Docker image.
Describe the bug
Partial update of a "single" component field results in invalid data.
Steps to reproduce the behavior
- Create a component with two required fields of any type.
// /src/components/category/component.json { "collectionName": "components_category_my-component", "info": { "displayName": "My Component", }, "options": {}, "attributes": { "field_1": { "type": "string", "required": true }, "field_2": { "type": "string", "required": true, } } }
- Create a content-type with a non-repeatable component field that uses the component:
// /src/api/my-type/contnent-types/my-type/shema.json { "kind": "collectionType", "collectionName": "my-type", "info": { "singularName": "my-type", "pluralName": "my-types", "displayName": "My Type" }, "options": { "draftAndPublish": false }, "pluginOptions": {}, "attributes": { "component_field": { "type": "component", "repeatable": false, "component": "category.my-component", "required": true } } }
- Allow
publicrole to crate and update the content type:

- Create an entry of the content type:
POST /api/my-types { data: { component_field: { field_1: "value", field_2: "value" } } }
5. Update one of the fields of the component using the REST API:
```
PUT /api/my-types/1?populate=*
{
data: {
component_field: {
field_1: "new value",
}
}
}
- Observe that
field_2gets nulled resulting in invalid entry:{ data: { id: 1, attributes: { component_field: { field_1: "new value", field_2: null } }, meta: {} }, meta: {} }
Expected behavior
Only field_1 is updated to "new value" and field_2 keeps its value or HTTP 400 is returned stating that field_2 cannot be null.
Additional context
I posted about this on the Strapi forum: https://forum.strapi.io/t/partial-update-of-single-component-field-results-in-invalid-data/23195
Metadata
Metadata
Assignees
Labels
issue: discussionA general discussion issueA general discussion issueseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solveIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: core:strapiSource is core/strapi packageSource is core/strapi packagestalestale-before-2023status: confirmedConfirmed by a Strapi Team member or multiple community membersConfirmed by a Strapi Team member or multiple community members
Type
Projects
Status
Fixed/Shipped