strapi / strapi

🚀 Strapi is the leading open-source headless CMS. It’s 100% JavaScript/TypeScript, fully customizable, and developer-first.
https://strapi.io
Other
63.81k stars 8.13k forks source link

Implicitly updating component fields on a record fails silently #20898

Closed nikita-fuchs closed 2 months ago

nikita-fuchs commented 3 months ago

Bug report

Required System information

Environment: development OS: darwin-x64 Strapi Version: 4.11.4 Node/Yarn Version: npm/9.6.7 node/v18.17.1 darwin x64 workspaces/false Edition: Community Database: postgres Is your project Javascript or Typescript: TS

Describe the bug

When updating a record and providing data for populated fields, the update operation fails silently.

Steps to reproduce the behavior

  1. Have a user record like this:
    let original = 
    {
    id: 74,
    username: 'su-tech',
    email: 'something@somethingsomething.com',
    provider: 'local',
    confirmed: true,
    blocked: false,
    createdAt: '2024-07-29T08:44:45.503Z',
    updatedAt: '2024-07-29T12:53:27.778Z',
    matricule: null,
    notes: 'technical admin account',
    validuntil: '2038-06-30T22:00:00.000Z',
    phone: null,
    markedForDeletion: false,
    firstName: 'N',
    lastName: 'N',
    birthDate: null,
    address: null,
    mobile: null,
    version: '0',
    hide_from_children: true,
    twoFA: { id: 151, twoFAmethod: 'email' }
    }

where twoFA is a component, consisting only of an enum called twoFAmethod.

  1. Have a cloned JSON object of this record and alter one or more properties, e.g. firstName, omit id of course, but leave the populated field twoFA :
let alteredClone = {
username: 'su-tech',
  email: 'something@something.com',
  provider: 'local',
  confirmed: true,
  blocked: false,
  createdAt: '2024-07-29T08:44:45.503Z',
  updatedAt: '2024-07-29T12:53:27.778Z',
  matricule: null,
  notes: 'technical admin account',
  validuntil: '2038-06-30T22:00:00.000Z',
  phone: null,
  markedForDeletion: false,
  firstName: 'Foo',
  lastName: 'Bar',
  birthDate: null,
  address: null,
  mobile: null,
  version: '0',
  hide_from_children: true,
  twoFA: { id: 151, twoFAmethod: 'email' }
  }
  1. Update the first record with the clone:
    let updatedAdminRecord = await strapi.entityService.update('plugin::users-permissions.user', original.id , { 
                    data: clone})

At this point, the execution of everything beyond this code is interrupted and a 500 server error is returned in the request, but there is no error thrown in the console itself. If you wrap this into a try-catch clause, you never land inside the catch clause and it seems like the operation was successful, although it wasn't performed.

Expected behavior

An error is thrown, signaling I did something I should have done in a different way.

Feel free to close if this is fixed in a more recent version, of course.

nikita-fuchs commented 3 months ago

I was able to narrow it down a bit: the id on the nested data is what is causing this issue. If you change the updating data to

...
  twoFA: { twoFAmethod: 'email' }
  }

this issue doesn't appear.

derrickmehaffy commented 3 months ago

Unable to reproduce on latest version of v4, advise upgrading to a newer version as 4.11.x is quite old now.

github-actions[bot] commented 3 months ago

This is a templated message

Hello @nikita-fuchs,

Thank you for reporting this bug, however we are unable to reproduce the issue you described given the information we have on hand. Can you please create a fresh project that you are able to reproduce the issue in, provide clear steps to reproduce this issue, and either upload this fresh project to a new GitHub repo or compress it into a .zip and upload it on this issue?

We would greatly appreciate your assistance with this, by working in a fresh project it will cut out any possible variables that might be unrelated. Please note that issues labeled with status: can not reproduce will be closed in 14 days if there is no activity.

Thank you!

github-actions[bot] commented 2 months ago

Hello!

As we have not received any new or updated information to reproduce this issue in the last 14 days we are marking this issue as closed. Should you have new information please feel free to respond and we will consider reopening it.

If anyone else have updated information for this issue, please open up a new bug report and simply reference this closed bug report so that we can get any new information you may have. If you have questions please refer to the contributor's guide on opening issues.

Thank you and have a great day!