Skip to content

fix(renderers): loosen client-side component validation to allow unknown properties - #2325

Open
nan-yu wants to merge 11 commits into
a2ui-project:mainfrom
nan-yu:relax-validation
Open

fix(renderers): loosen client-side component validation to allow unknown properties#2325
nan-yu wants to merge 11 commits into
a2ui-project:mainfrom
nan-yu:relax-validation

Conversation

@nan-yu

@nan-yu nan-yu commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

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:
    • Removed .strict() from all basic component Zod schemas (TextApi, ButtonApi, TextFieldApi, SliderApi, etc.).
    • Updated MessageProcessor.processUpdateComponentsMessage to filter out unrecognized_keys Zod validation issues while continuing to reject invalid property types.
    • Verified GenericBinder treats unrecognized properties as static values in reactive snapshots.
  • Renderers & Framework Adapters:
    • Verified and tested that @a2ui/react, @a2ui/lit, @a2ui/angular, and A2UISwiftUI tolerate unrecognized component properties without rendering or lifecycle issues.
  • Tests:
    • Added unit and integration tests across @a2ui/web_core, @a2ui/react, @a2ui/lit, @a2ui/angular, and swift/core.
  • Documentation:
    • Updated CHANGELOG.md files 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread renderers/web_core/src/v0_9/processing/message-processor.ts Outdated
nan-yu added 2 commits August 18, 2026 17:14
…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.
@nan-yu
nan-yu requested review from gspencergoog and wrenj August 18, 2026 17:19
Comment thread renderers/web_core/src/v0_9/processing/message-processor.test.ts
Comment thread renderers/angular/src/v0_9/v0_9_integration.spec.ts
nan-yu added 9 commits August 18, 2026 17:51
…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',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should do it for functions too?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and any other things in the catalog that could get out of date?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants