Skip to content

A2uiMessage.fromJson accepts objects carrying more than one of createSurface/updateComponents/updateDataModel/deleteSurface #934

@andrewkolos

Description

@andrewkolos

A2uiMessage.fromJson. The message type is parsed in the order of 1) createSurface, 2) updateComponents, 3) updateDataModel, and then 4) deleteSurface). The function returns on the first match.

A payload that matches multiple of these checks will silently parse as whatever happens to come first instead of failing validation.

final message = A2uiMessage.fromJson({
  'version': 'v0.9',
  'createSurface': {'surfaceId': 's1', 'catalogId': 'c1'},
  'updateComponents': {'surfaceId': 's1', 'components': <Object?>[]},
});
// Expected: A2uiValidationException
// Actual: parses as CreateSurface, drops updateComponents silently

I would normally consider this a corner case and not bother with fixing it, as I think an LLM is very unlikely to generate a message that matches multiple types. However, 1) I'd like package:genui to have as much parity with other renderers as possible (web_core does include logic to catch this case) and 2) the 0.9 spec does explicitly specify oneOf and additionalProperties: false for each message type, so fixing this would also make the genui package follow the spec more closely.

Metadata

Metadata

Assignees

Labels

front-line-handledCan wait until the second-line triage. The front-line triage already checked if it's a P0.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions