Repository navigation
fix(@angular-devkit/core): name the unknown option in a schema validation error - #34113
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves JSON schema validation error messages by formatting unknown property errors into a more user-friendly 'Unknown option' format, listing valid options where possible. To enable this, the Ajv validator is configured with 'verbose: true'. The changes also include updated and new unit and end-to-end tests. The feedback suggests ensuring TypeScript type safety when accessing 'err.parentSchema', as it can be a boolean and might cause compilation errors when accessing '.properties' directly.
…tion error An unknown property in `angular.json` or in a builder's options reported `Data path "" must NOT have additional properties(allowedCommonJsDependencies).`, which names neither the object the property was found in nor what is valid there. It now reads `Unknown option "allowedCommonJsDependencies". Valid options are: assets, browser, ...`, with `at "/cli"` where the instance path is not empty. Errors that are not about an unknown option are unchanged. Listing the valid options needs ajv's `verbose` option, which is what puts `parentSchema` on an error. That is the schema the property was rejected by, so a `$ref` and a `oneOf` branch each list their own options; a schema that declares no `properties` at all stops after the option name rather than offering an empty list.
1ddd272 to
5730461
Compare
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
A typo in
angular.jsonor in a builder's options reports which property is unknown, but neither the object it was found in nor what is valid there:Issue Number: #11479
What is the new behavior?
and with a non-empty instance path:
Other errors keep what they said, with the
Data pathprefix replaced:Option at "/outputPath" must be string.Listing the valid options needs ajv's
verboseoption, which is what putsparentSchemaon an error.The issue also asks for the project and target an error came from. That needs the caller to pass it in, so it isn't part of this PR.
Does this PR introduce a breaking change?
Closes : #11479