Skip to content

Added null checks on context messages #18728

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 3 commits into
base: main
Choose a base branch
from

Conversation

AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Mar 19, 2025

Description

Not 100% sure if this is a useful guard or masking an underlying issue, but in investigating issues with nested blocks and validation on a customer database I found lots of errors like the following:

validation.controller.ts:58 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'addTranslator')
    at et.addTranslator (validation.controller.ts:58:17)
    at UmbContextConsumerController.<anonymous> (validation-path-translator-base.controller.ts:19:12)
    at UmbContextConsumerController.setInstance (context-consumer.js:92:25)
    at UmbContextConsumer._onResponse [as callback] (context-consumer.js:43:22)
    at #handleContextRequest (context-provider.js:61:56)
    at UmbContextConsumerController.request (context-consumer.js:122:85)
    at UmbContextConsumerController.hostConnected (context-consumer.js:128:14)
    at controller-host.mixin.js:85:54
    at Array.forEach (<anonymous>)
    at l.hostConnected (controller-host.mixin.js:85:31)

observe-validation-state.controller.ts:17 Uncaught TypeError: Cannot read properties of undefined (reading 'hasMessagesOfPathAndDescendant')
    at UmbContextConsumerController.<anonymous> (observe-validation-state.controller.ts:17:35)
    at UmbContextConsumerController.setInstance (context-consumer.js:92:25)
    at UmbContextConsumer._onResponse [as callback] (context-consumer.js:43:22)
    at #handleContextRequest (context-provider.js:61:56)
    at UmbContextConsumerController.request (context-consumer.js:122:85)
    at UmbContextConsumerController.hostConnected (context-consumer.js:128:14)
    at controller-host.mixin.js:85:54
    at Array.forEach (<anonymous>)
    at Mt.hostConnected (controller-host.mixin.js:85:31)
    at controller-host.mixin.js:85:54

form-control-validator.controller.ts:33 Uncaught TypeError: Cannot read properties of undefined (reading 'getHasMessagesOfPathAndDescendant')
    at UmbContextConsumerController.<anonymous> (form-control-validator.controller.ts:33:37)
    at UmbContextConsumerController.setInstance (context-consumer.js:92:25)
    at UmbContextConsumer._onResponse [as callback] (context-consumer.js:43:22)
    at #handleContextRequest (context-provider.js:61:56)
    at UmbContextConsumerController.request (context-consumer.js:122:85)
    at UmbContextConsumerController.hostConnected (context-consumer.js:128:14)
    at controller-host.mixin.js:85:54
    at Array.forEach (<anonymous>)
    at xt.hostConnected (controller-host.mixin.js:85:31)
    at xt.hostConnected (form-control-validator.controller.ts:84:9)

I've resolved in this PR with null checks on the context.messages element that is undefined in some situations.

# Conflicts:
#	src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/bind-server-validation-to-form-control.controller.ts
#	src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/validation.controller.ts
@iOvergaard iOvergaard changed the base branch from v15/dev to main May 5, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant