I’m doing a work-around for the year+ old RBAC bug that keeps reseting required text fields configured as “not updatable” (RBAC permissions resets on required fields when restarting Strapi · Issue #16890 · strapi/strapi · GitHub) in a lifecycle. Basically, I’m adding a check in beforeUpdate to ensure the content in the field that should not be editable hasn’t been changed. I tested multiple times on my local instance and didn’t run into any issues when I did various tests (only updating field that shouldn’t be updated, updating only other fields, updating combinations of the two, etc).
Of course, I’ve deployed to prod and my first edit of another field caused reported an error as if I had edited the field that shouldn’t be modified. I had to go at it several times before I could recreate it locally and it seems the issue is the field in question is sometimes not included in event.params.data so my check fails cause I end up comparing null against the value looked up via entityService. Why would this happen? I though all root-fields (not relations or components) always were included in event.params.data?
Unfortunately, I can’t recreate it 100% of the time as it’s completely random. I’ll work around it by adding a check if the field is there (easy but come on).
Expected params.data :
boutique: beforeUpdate
event.params.data: {
id: 1,
description: 'Ampoulesfds',
ident: '1',
categories: { disconnect: [], connect: [] },
updatedBy: 3,
updatedAt: 2024-08-14T16:13:01.045Z
}
Randomly (no ‘ident’ field):
boutique: beforeUpdate
event.params.data: {
id: 1,
description: 'Ampoulesdd',
categories: { disconnect: [], connect: [] },
updatedBy: 3,
updatedAt: 2024-08-14T16:11:31.637Z
}
This topic has been created from a Discord post (1273328781884395662) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord