Visitar URL original
Reactive Forms: formControlName with no matching control crashes in production with a raw TypeError · Issue #71155 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20261014135334/https://github.com/angular/angular/issues/71155
Skip to content

Reactive Forms: formControlName with no matching control crashes in production with a raw TypeError #71155

Open

Description

@arturovt

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

forms

Is this a regression?

No

Description

If the template renders a formControlName for a control that the FormGroup doesn't have, the error depends on the build:

  • Dev mode: Error: Cannot find control with path: 'Options -> 2', which is clear.
  • Production: TypeError: Cannot read properties of null (reading '_rawValidators'). It says nothing about forms or which control is missing, so it is hard to trace back to the template.

A real-world way to hit this: the template and the FormGroup are built from the same list but with two different filters. An item passes the template's filter but not the form's, so the template asks for a control that was never added.

Cause: AbstractFormDirective.addControl() passes the result of this.form.get(dir.path) on without checking it for null. In dev mode, a ngDevMode-only check in setUpControlValueAccessor catches it. That check is stripped from production builds, so the null control reaches setUpValidators, which uses it right away.

Expected: a clear, coded error in production too, instead of a bare TypeError.

Please provide a link to a minimal reproduction of the bug

https://github.com/arturovt/form-control-name-missing-control-repro

Please provide the exception or error you saw

Production build:
TypeError: Cannot read properties of null (reading '_rawValidators')

Dev build:
Error: Cannot find control with path: 'Options -> 2'

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

Angular CLI       : 22.2.1
Angular           : 22.2.1
Node.js           : 24.15.0
Package Manager   : pnpm 10.33.4
Operating System  : darwin x64

@angular/build             22.2.1
@angular/cli               22.2.1
@angular/common            22.2.1
@angular/compiler          22.2.1
@angular/compiler-cli      22.2.1
@angular/core              22.2.1
@angular/forms             22.2.1
@angular/platform-browser  22.2.1
@angular/router            22.2.1
rxjs                       7.8.2
typescript                 6.0.3

Activity

  1. added this to the needsTriage milestone on Oct 3, 2026
  2. added this to the needsTriage milestone on Oct 3, 2026
  3. arturovt commented on Oct 3, 2026

    @arturovt
    ContributorAuthor

    note: i already have a fix, just waiting for PRs to reduce...

  4. MeAkib commented on Oct 3, 2026

    @MeAkib
    Contributor

    note: i already have a fix, just waiting for PRs to reduce...

    You can create a draft PR

  5. arturovt commented on Oct 3, 2026

    @arturovt
    ContributorAuthor

    AI will close it, 10 PRs is a limit.

  6. erkamyaman commented on Oct 3, 2026

    @erkamyaman
    Contributor

    It doesn't actually, 10 PRs limit is only for open ones so drafts are okay

  7. arturovt commented on Oct 3, 2026

    @arturovt
    ContributorAuthor

    @JeanMeche could you confirm?

  8. JeanMeche commented on Oct 3, 2026

    @JeanMeche
    Member

    Yes, but we would prefer that our contributors understand that having too many open PRs at once makes it difficult for us to review and maintain a sustainable pace. We really appreciate your contributions and enthusiasm, but we'd encourage you to focus on a smaller number of PRs at a time so we can give each one the attention it deserves.

  9. arturovt commented on Oct 3, 2026

    @arturovt
    ContributorAuthor

    Exactly, I'll open it later if you guys @MeAkib @erkamyaman don't mind :D :D

  10. arturovt commented on Oct 3, 2026

    @arturovt
    ContributorAuthor

    Hoping Matt R not gonna close it immediately :D

  11. added 2 commits that reference this issue on Oct 4, 2026
    6aecc51
    aa6349c
  12. thePunderWoman commented on Oct 5, 2026

    @thePunderWoman
    Contributor

    @erkamyaman The draft PR workaround is only temporary. There's an incoming feature from github that will enable similar limits on draft PRs. We would strongly encourage you all to be aware of those limits and be respectful of them. As @JeanMeche said, the high level of PRs puts a high, unsustainable burden on the maintainers. This is happening for many open source repos. So please be considerate.

  13. erkamyaman commented on Oct 5, 2026

    @erkamyaman
    Contributor

    Thank you for explaining it all @thePunderWoman 🙏 I always follow the rules and will carry on doing so. And I appreciate how much you all care about community PRs. That's one of the many reasons why Angular is one of the best communities out there 💙

  14. added 3 commits that reference this issue on Oct 7, 2026
    a563dea
    8300518
    8bc71f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: formsgemini-triagedLabel noting that an issue has been triaged by gemini

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions