fix(renderers): loosen client-side component validation to allow unknown properties - #2325
fix(renderers): loosen client-side component validation to allow unknown properties#2325nan-yu wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request loosens client-side component validation across Angular, Lit, React, Web Core, and Swift renderers to support unrecognized and legacy component properties without throwing errors. This is done by removing .strict() from Zod schemas in Web Core, filtering out unrecognized_keys validation issues in MessageProcessor, and updating binders to pass through unrecognized properties. The reviewer noted that filtering only unrecognized_keys at the top level in MessageProcessor is insufficient when a component schema uses z.union of strict objects, as unrecognized keys will result in an invalid_union error instead, and suggested recursively checking unionErrors.
…own properties Loosens client-side component validation so older messages and unrecognized properties do not throw validation errors when rendered on the client: - Removes .strict() from all v0.9 basic component Zod schemas in web_core. - Filters out unrecognized_keys issues during MessageProcessor component validation. - Confirms GenericBinder, Angular ComponentBinder, and Swift MessageProcessor treat unrecognized properties as static/inert values. - Adds comprehensive unit and integration tests across web_core, React, Lit, Angular, and Swift test suites. - Updates CHANGELOGs for web_core, Angular, Lit, and React packages.
…rors in MessageProcessor Addresses review feedback on PR a2ui-project#2325 by adding filterZodRealIssues to recursively check unionErrors when evaluating invalid_union issues, ensuring that unrecognized keys on union branches of strict schemas are properly ignored during client-side validation.
7128016 to
bf277c5
Compare
…onent types Adds tests across web_core, React, Lit, Angular, and Swift to verify that unrecognized component types: - Are accepted by MessageProcessor without throwing validation errors. - Degrade gracefully in React, Lit, Angular, and SwiftUI views without crashing or breaking surrounding component rendering.
- Fix Swift Testing macro failure on Optional<AnyView> comparison. - Allow Swift MessageProcessor to accept and store unrecognized components gracefully. - Add warning logs for unrecognized components and unrecognized property keys in both TypeScript and Swift MessageProcessors. - Add extractUnrecognizedKeys helper to recursively extract unrecognized keys from union branches. - Fix catalog ID injection in Angular unrecognized component integration test.
| surfaceId: 'test-surface', | ||
| components: [ | ||
| { | ||
| id: 'root', |
There was a problem hiding this comment.
I guess we should do it for functions too?
There was a problem hiding this comment.
and any other things in the catalog that could get out of date?
Summary
Loosens client-side component schema validation across renderers so that messages containing unrecognized properties (such as older conversation history or forward-compatible properties) render without throwing validation errors. Agent-side payload validation remains strict (
additionalProperties: false).Changes
@a2ui/web_core:.strict()from all basic component Zod schemas (TextApi,ButtonApi,TextFieldApi,SliderApi, etc.).MessageProcessor.processUpdateComponentsMessageto filter outunrecognized_keysZod validation issues while continuing to reject invalid property types.GenericBindertreats unrecognized properties as static values in reactive snapshots.@a2ui/react,@a2ui/lit,@a2ui/angular, andA2UISwiftUItolerate unrecognized component properties without rendering or lifecycle issues.@a2ui/web_core,@a2ui/react,@a2ui/lit,@a2ui/angular, andswift/core.CHANGELOG.mdfiles for@a2ui/web_core,@a2ui/angular,@a2ui/lit, and@a2ui/react.Verification
yarn test:all: All workspace test suites passed.yarn lint:all: Linters passed.yarn format:check:all: Formatting checks passed.