Signal Forms: `validateStandardSchema` throws a TypeError for an issue whose path runs through a key the model lacks

オープン 初心者向け
#71,128 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@rene-schakmann がすでに取り組んでいます。

2026年10月3日 から。

  • #71153 @rene-schakmann による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
angular, typescript
領域
frontend

調査の方向性

@angular/forms/signals の validateStandardSchema で使用されている standardIssueToFormTreeError() の実装から始め、次にこの issue の最小再現を ['ghost'] と ['ghost', 'name'] の両方に対して実行します。中間キーのケースでスローされなくなり、未知の末尾キーのフォールバックと同様に、ルート上に Wrong. エラーが 1 つ報告されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

area: forms gemini-triaged
Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

No

Description

standardIssueToFormTreeError() walks an issue's path with target = target[pathKey]. For an unknown last key, target ends up undefined and the error falls back to the field the schema validates, which is fine. For an unknown key anywhere before the last one, the next step reads a property of undefined, and reading errors() throws.

import { signal } from '@angular/core';
import { form, validateStandardSchema } from '@angular/forms/signals';
import type { StandardSchemaV1 } from '@standard-schema/spec';

function reportsOn(path: PropertyKey[]): StandardSchemaV1<{ name: string }> {
  return {
    '~standard': {
      version: 1,
      vendor: 'repro',
      validate: () => ({ issues: [{ message: 'Wrong.', path }] }),
    },
  };
}

// In an injection context:
const lastKey = form(signal({ name: '' }), (p) => validateStandardSchema(p, reportsOn(['ghost'])));
lastKey().errors(); // one error, 'Wrong.', on the root

const middleKey = form(signal({ name: '' }), (p) => validateStandardSchema(p, reportsOn(['ghost', 'name'])));
middleKey().errors(); // TypeError: Cannot read properties of undefined (reading 'name')

A Standard Schema can easily report outside the bound model: a schema written for a wider object, a refinement with a computed path, a Vest test whose name is not a model key. Today one such issue makes errors() throw.

Expected: the same fallback as for an unknown last key. target = target?.[pathKey] in that loop would give it.

Minimal reproduction

The snippet above.

Exception or error

TypeError: Cannot read properties of undefined (reading 'name')

Environment

Angular CLI 22.2.0, Angular 22.2.0, Node.js 26.7.0, darwin arm64. standardIssueToFormTreeError() is the same in 22.2.1, 22.3.0-next.0 and on main.

Anything else?

No.

主要言語
TypeScript
スター
102k
フォーク
28.2k
平均マージ
2日 10分
マージ済み PR(30日)
402

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

angular/angular のほかの issue

angular/angular の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。