New client response error "Required attribute: contentInLocales"

Hi there,

I built and maintain ringofkeys.org, which uses Dato and Auth0 to allow our members to edit their profiles, which are simple Dato entries. Itā€™s worked very reliably for going on 3 years now across a Gatsby and now NextJS frontend, so first off thank you for building this platform!

Recently my users have been unable to edit profiles, and my Netlify function for updating their profile fields returns the following error response:

{
  message: "Required attribute: contentInLocales"
}

I havenā€™t been able to find any reference to a contentInLocales attribute anywhere in the documentation, so Iā€™m unsure where or how to add this attribute to my payload. Is this is a per-field sort of localization attribute?

Here are my JS client versions:

  • ā€œ@datocms/cma-client-browserā€: ā€œ^1.1.12ā€
  • ā€œ@datocms/cma-client-nodeā€: ā€œ^1.1.12ā€

I also just retried after updating them to 2.0.0, but I didnā€™t expect it to change anything and it didnā€™t.

To make my updates to the profile entries, within the updateKey Netlify function (source code here, sorry I havenā€™t gotten to migrate it to TS yet), simply passing the new payload from their edited profile field into the client.item.update() function.

This has worked well for a long time, so Iā€™m uncertain what could have changed? We have just one default locale, en, so I donā€™t know what localization constraint is being imposed here.

Hello @frank.ringofkeys ,

Now you can publish only select locales so the structure of the call has changed, with new required parameters: Publish a record - Record - Content Management API

However, the old way to do the calls should be compatible with this change, and should not error out.
Are you using the /cma-client-node 2.0.0 to do those calls? Iā€™ll try and reproduce this issue and get back to you as soon as possible.

In the meantime, changing the call to reflect Publish a record - Record - Content Management API should work, sorry about this!

Thanks @m.finamor! I had been looking at the docs to update a record, and hadnā€™t traced the error thoroughly enough to determine that itā€™s only required when publishing, which I also do in that function. Iā€™ll add that parameter and check again, then get back here.

No I started seeing the errors even as I continued to use ^1.1.12 of cma-client-node; I only tried bumping the version as a naive last attempt to get a different error. I may be missing something, but it does appear to be a backwards compatibility break.

@m.finamor Iā€™m running into an issue with this command - when i pass [' '] to content_in_locales when trying to publish a record with the API, I keep getting an error with content_in_locales even though all code samples use this value.

422 Unprocessable Entity

[
  {
    "id": "xxx",
    "type": "api_error",
    "attributes": {
      "code": "INVALID_FIELD",
      "details": {
        "field": "content_in_locales",
        "code": "VALIDATION_INVALID"
      }
    }
  }
]

@frank.ringofkeys, sorry, this seems to have fallen through the cracks a few months ago!

We are re-investigating this issue now as a bug and Iā€™ll let you know what we find. Sorry for the delay!

In the meantime (if itā€™s not too lateā€¦) there is a workaround described here: `content_in_locales` field in publish API function - #2 by roger