Signal Forms: `validateStandardSchema` throws a TypeError for an issue whose path runs through a key the model lacks
維護者通常 1 天內回覆
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 78/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- angular, typescript
- 領域
- frontend
研究方向
從 @angular/forms/signals 中 validateStandardSchema 使用的 standardIssueToFormTreeError() 實作開始,然後針對 ['ghost'] 和 ['ghost', 'name'] 執行此 issue 的最小重現。完成的標準是中間鍵的情況不再擲出例外,並在根上回報一個 Wrong. 錯誤,與未知末尾鍵的 fallback 行為一致。
由索引模型根據 Issue 內容生成。
描述
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 分鐘
- 30 天內合併 PR
- 402
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
angular/angular 的其他 Issue
-
Two-way binding documentation is missing important information可能重新可做 關聯的 PR 已關閉且未合併。 未關閉area: docs
難度 2/5 1-3 小時 新手友好度 75/100
angular/angular#71796 · 2 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
area: core
難度 2/5 1-3 小時 新手友好度 78/100
angular/angular#71585 · 3 則留言 ·
維護者通常 1 天內回覆
-
Assigning to a template reference in an event binding isn't reported by the compiler可能重新可做 關聯的 PR 已關閉且未合併。 未關閉area: compiler
難度 2/5 1-3 小時 新手友好度 74/100
angular/angular#71511 · 3 則留言 ·
維護者通常 1 天內回覆
-
`Symbol.iterator in FieldTree` is always false可能重新可做 關聯的 PR 已關閉且未合併。 未關閉area: forms forms: signals
難度 2/5 1-3 小時 新手友好度 78/100
angular/angular#70252 · 3 則留言 ·
維護者通常 1 天內回覆
-
area: docs gemini-triaged
難度 2/5 1-3 小時 新手友好度 70/100
angular/angular#68808 · 7 則留言 ·
維護者通常 1 天內回覆
相似的 Issue
-
難度 1/5 1-3 小時 新手友好度 83/100
gofish-graphics/gofish-graphics#1384 ·
維護者通常 1 天內回覆
-
adapter bug
難度 2/5 1-3 小時 新手友好度 83/100
Olanetsoft/agent-lookout#353 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
vicharanashala/vibe#1542 ·
維護者通常 1 天內回覆
-
bug chore P2 size:XS
難度 2/5 1-3 小時 新手友好度 77/100
josephfung/curia#2666 ·
維護者通常 1 天內回覆
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 84/100
devarshishimpi/codra#178 ·
維護者通常 1 天內回覆