Skip to content

fix(web_core): validate component properties against catalog schema in message processor - #2142

Merged
gspencergoog merged 5 commits into
a2ui-project:mainfrom
gspencergoog:fix-malformed-action-validation
Jul 31, 2026
Merged

fix(web_core): validate component properties against catalog schema in message processor#2142
gspencergoog merged 5 commits into
a2ui-project:mainfrom
gspencergoog:fix-malformed-action-validation

Conversation

@gspencergoog

@gspencergoog gspencergoog commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes an issue where malformed component properties (such as specifying "action": { "call": "openUrl", "args": { "url": "..." } } instead of a valid event or wrapped function call) were accepted into component models without schema validation, causing DataContext to immediately execute function calls on component mount without user interaction.

Changes

  • Catalog Schema Validation (MessageProcessor): Validate incoming component properties against surface.catalog.components.get(componentType)?.schema in processUpdateComponentsMessage. Throws A2uiValidationError if validation fails.
  • Schema Updates (common-types.ts, basic_components.ts):
    • Added optional isValid and validationErrors fields to CheckableSchema and spread ...CheckableSchema.shape across checkable components.
    • Made action optional (ActionSchema.optional()) on ButtonApi.
  • Tests:
    • Added unit test in message-processor.test.ts to verify rejection of malformed component properties.
    • Updated Angular mock dataset to remove obsolete style: "italic" property.

Verification

  • yarn workspace @a2ui/web_core test (281 tests passing)
  • yarn workspace @a2ui/lit test:unit (96 tests passing)
  • yarn workspace @a2ui/react test (passing)
  • yarn workspace @a2ui/angular test:unit (256 tests passing)

…n message processor

Validate incoming component properties against the component's catalog schema in MessageProcessor.processUpdateComponentsMessage. Malformed component payloads (such as malformed actions with direct "call" properties) are rejected immediately with an A2uiValidationError.

Also update CheckableSchema to include optional isValid and validationErrors fields so component validation states can be provided in properties, and make action optional on ButtonApi.
gemini-code-assist[bot]

This comment was marked as resolved.

gspencergoog and others added 2 commits July 31, 2026 21:09
… Zod errors

Address PR feedback:
1. Format Zod errors into clean, human-readable strings.
2. Separate processUpdateComponentsMessage into a validation pass and a mutation pass to guarantee atomic state updates.
@gspencergoog
gspencergoog force-pushed the fix-malformed-action-validation branch 2 times, most recently from 9bf018e to 074ddc8 Compare July 31, 2026 21:36
…mon-types for closure compiler compatibility

Closure Compiler (1P advanced minification) renames unquoted object keys in Zod schemas (e.g. children, justify, align -> a, b, c), causing safeParse on incoming JSON objects to fail. Quoting the property keys ensures Closure Compiler preserves them.
@gspencergoog
gspencergoog force-pushed the fix-malformed-action-validation branch from 074ddc8 to 03505b1 Compare July 31, 2026 21:39
…api for closure compiler compatibility

Quote all property keys in DataBindingSchema, FunctionCallSchema, ChildListSchema, ActionSchema, CheckRuleSchema, and basic function argument schemas so Closure Compiler does not minify key names during advanced optimization builds.

@nan-yu nan-yu left a comment

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.

LGTM. This has been identified as a missing coverage in the current MessageProcessor, https://docs.google.com/document/d/17BuULV88IlsUStOFthGMgfeW1XMtLUyQDm3oflgXi-k/edit?pli=1&resourcekey=0-fltDWdFS4VEdDHSTzq--QA&tab=t.lcmh7rwipp8t#bookmark=id.576fjubtmldj.

The new web a2ui_core will run more sophisticated validation, including catalog schema checks, and more.

@gspencergoog

Copy link
Copy Markdown
Collaborator Author

The new web a2ui_core will run more sophisticated validation, including catalog schema checks, and more.

Oh, good!

@gspencergoog
gspencergoog merged commit 50cc470 into a2ui-project:main Jul 31, 2026
22 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in A2UI Jul 31, 2026
@ditman

ditman commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

I'm surprised there's not an existing issue for this very thing on the web renderers, but I can't find it :/

gspencergoog added a commit that referenced this pull request Jul 31, 2026
…n message processor (#2145)

Added a missing CHANGELOG.md entry for #2142
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.

3 participants