Skip to content

Unhelpful error: Cannot read properties of null (reading '_rawValidators') #57236

@arobinson

Description

@arobinson

Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

No

Description

Error thrown: Cannot read properties of null (reading '_rawValidators')

This does not tell the user where the issue is (what component), nor what the invalid form control name is. There is better handling when production mode is not on, but this doesn't help when we are trying to debug an issue that is in our production environment and do not know how to reproduce the issue.

We log unhandled errors to DataDog and when we get this error, there is pretty much nothing we can do to take action on it or fix it since there is no useful information provided in the stack trace.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-cgg4uh?file=src%2Fapp%2Fforms%2Fforms.component.html

Please provide the exception or error you saw

TypeError: Cannot read properties of null (reading '_rawValidators')
    at getControlValidators (@angular_forms.js?v=a1e73860:721:18)
    at setUpValidators (@angular_forms.js?v=a1e73860:2545:22)
    at setUpControl (@angular_forms.js?v=a1e73860:2500:3)
    at _FormGroupDirective.addControl (@angular_forms.js?v=a1e73860:4087:5)
    at _FormControlName._setUpControl (@angular_forms.js?v=a1e73860:4611:39)
    at _FormControlName.ngOnChanges (@angular_forms.js?v=a1e73860:4560:12)
    at _FormControlName.rememberChangeHistoryAndInvokeOnChangesHook (chunk-H7PDWKI7.js?v=a1e73860:5775:10)
    at callHookInternal (chunk-H7PDWKI7.js?v=a1e73860:6341:10)
    at callHook (chunk-H7PDWKI7.js?v=a1e73860:6359:5)
    at callHooks (chunk-H7PDWKI7.js?v=a1e73860:6330:9)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.3.8
Node: 18.20.3
Package Manager: npm 10.2.3
OS: linux x64

Angular: 17.3.12
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1703.8
@angular-devkit/build-angular   17.3.8
@angular-devkit/core            17.3.8
@angular-devkit/schematics      17.3.8
@angular/cli                    17.3.8
@schematics/angular             17.3.8
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.8

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions