404 error of id returned by api

I think this must be a bug because I don’t understand what I could be doing wrong. I have a few records that I want to fill a certain property, so I first look for the records and then use the id of each one to make an update. Here is the code:

async function main() {
    const client = buildClient({ apiToken: X });
    const recommenders = await client.items.list({filter: {type: 2635038}})
    await recommenders
        .filter((item) => item.variant === '')
        .reduce(async (previousPromise, item) => {
        try {
            await previousPromise
            await client.items.update(item.id, {variant: 'discreet'})
        } catch (e) {
            console.error(e)
        }
    }, Promise.resolve())
}

main();

This is an example of the response from one of the records:

{
	"id": "205467339",
	"type": "item",
	"question": "203888330",
	"variant": "",
	"updated_at": "2023-10-03T13:10:01.417+01:00",
	"created_at": "2023-10-03T13:10:01.413+01:00",
	"item_type": {
		"id": "2635038",
		"type": "item_type"
	},
	"meta": {
		"created_at": "2023-10-03T13:10:01.413+01:00",
		"updated_at": "2023-10-03T13:10:01.417+01:00",
		"published_at": "2023-10-03T13:38:17.074+01:00",
		"publication_scheduled_at": null,
		"unpublishing_scheduled_at": null,
		"first_published_at": "2023-10-03T13:38:17.074+01:00",
		"is_valid": false,
		"is_current_version_valid": false,
		"is_published_version_valid": false,
		"status": "published",
		"current_version": "356379725",
		"stage": null
	}
}

This is the error I receive:

Error: PUT https://site-api.datocms.com/items/205467339: 404 Not Found

[
  {
    "id": "302048",
    "type": "api_error",
    "attributes": {
      "code": "NOT_FOUND",
      "details": {}
    }
  }
]

Hi @garoz.daniel , welcome to the forums!

I copied & pasted your code and it seems to work fine in my demo project. Hmm. Are you using the latest version of @datocms/cma-client-node (3.0.2)?

Could you please share your project URL with me so I can take a look? (Feel free to post it here, or if you don’t want it to be public, you can email us at support@datocms.com and CC me at r.tuan@datocms.com)