Content-Length: 293851 | pFad | http://github.com/umbraco/Umbraco-CMS/pull/19645

61 Ensure block values aren't null before attempting to process them on removal by AndyButland · Pull Request #19645 · umbraco/Umbraco-CMS · GitHub
Skip to content

Ensure block values aren't null before attempting to process them on removal #19645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndyButland
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Resolves: #19602

Description

Note that I couldn't replicate the reported issue, though as noted, it has come from an upgraded site so perhaps there are situations where the block content or settings data is undefined in older versions that we don't expect now.

The fix suggested on the reported issue looks reasonable to me and hence I've applied. Seems sensible as a guard against a null value here.

Testing

Verify that blocks can continue to be be removed from a block list and the document saved.

@Copilot Copilot AI review requested due to automatic review settings July 1, 2025 09:35
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces guard clauses to prevent null values in block content and settings data when processing block removal.

  • Uses nullish coalescing (??) to provide defaults for contentData and settingsData
  • Ensures the mapping functions always operate on an array

@@ -15,13 +15,13 @@ export abstract class UmbBlockValueResolver<ValueType>
valuesCallback: (values: Array<UmbBlockDataValueModel>) => Promise<Array<UmbBlockDataValueModel> | undefined>,
) {
const contentData = await Promise.all(
value.contentData?.map(async (entry) => ({
(value.contentData ?? []).map(async (entry) => ({
Copy link
Preview

Copilot AI Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the common mapping logic for both contentData and settingsData into a helper function to reduce duplication and improve maintainability.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in processValueBlockData when removing item - contentData or settingsData may be undefined
1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/umbraco/Umbraco-CMS/pull/19645

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy