FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(forms): handle standard schema issues whose path runs through unknown keys by rene-schakmann · Pull Request #71153 · angular/angular · GitHub

fix(forms): handle standard schema issues whose path runs through unknown keys - #71153

Open
rene-schakmann wants to merge 1 commit into
angular:mainfrom
rene-schakmann:fix/standard-schema-missing-path-71128
Open

rene-schakmann wants to merge 1 commit into
angular:mainfrom
rene-schakmann:fix/standard-schema-missing-path-71128

Conversation

Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

standardIssueToFormTreeError() walks a Standard Schema issue's path with target = target[pathKey]. When the last key is unknown to the model, target ends up undefined and the error falls back to the field being validated. When a key before the last one is unknown, the next step reads a property of undefined and errors() throws:

form(signal({name: ''}), (p) =>
  validateStandardSchema(p, z.object({name: z.string()}).superRefine((_, ctx) => {
    ctx.addIssue({code: 'custom', message: 'Wrong.', path: ['ghost', 'name']});
  })),
)().errors();
// TypeError: Cannot read properties of undefined (reading 'name')

Issue Number: #71128

What is the new behavior?

The path walk stops descending once it leaves the model (target?.[pathKey]), so the issue is reported on the field being validated, the same fallback that already applies when only the last key is unknown.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Added two tests to packages/forms/signals/test/node/api/validators/standard_schema.spec.ts: one for an unknown last key (existing behavior) and one for a path that runs through an unknown key. //packages/forms/signals/test/node:test passes locally (543 specs); without the fix the new test fails with the TypeError above.

An alternative would be to report the issue on the deepest existing field instead of the validated field. I kept the existing fallback for consistency, but happy to change it if preferred.

🤖 Generated with Claude Code

…nown keys

`validateStandardSchema` maps each issue onto a field by walking the issue's path through the
field tree. When a key before the last one doesn't exist in the model (e.g. the schema was written
for a wider object or a refinement reports a computed path), the next step read a property of
`undefined` and `errors()` threw a `TypeError`.

Such issues are now reported on the field being validated, which is the same fallback that is
already used when only the last key of the path is unknown.

Fixes angular#71128
pullapprove Bot requested a review from kirjs October 3, 2026 04:06
ngbot Bot added this to the Backlog milestone Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL