-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
Description
Which Umbraco version are you using?
16.0.0
Bug summary
When attempting to remove an item from a block list, an error is thrown in the processValueBlockData
method. This happens because value.contentData
and value.settingsData
can be undefined
, which causes the Promise.all()
mapping to fail.
The error seems to be related to migrated content from previous Umbraco-versions.
Update the code to safely handle undefined by defaulting to an empty array when contentData or settingsData are not present.
Current Code:
const contentData = await Promise.all(
value.contentData?.map(async (entry) => ({
...entry,
values: (await valuesCallback(entry.values)) ?? [],
})),
);
const settingsData = await Promise.all(
value.settingsData?.map(async (entry) => ({
...entry,
values: (await valuesCallback(entry.values)) ?? [],
})),
);
Suggested Change:
const contentData = await Promise.all(
(value.contentData ?? []).map(async (entry) => ({
...entry,
values: (await valuesCallback(entry.values)) ?? [],
})),
);
const settingsData = await Promise.all(
(value.settingsData ?? []).map(async (entry) => ({
...entry,
values: (await valuesCallback(entry.values)) ?? [],
})),
);
Video/screenshot demonstrating the error:
Specifics
No response
Steps to reproduce
See above.
Expected result / actual result
The removal should complete without error, regardless of whether contentData or settingsData exist.
An exception is thrown during the Promise.all() operation when either of the properties is undefined.