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.
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.
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:genuito have as much parity with other renderers as possible (web_coredoes include logic to catch this case) and 2) the 0.9 spec does explicitly specifyoneOfandadditionalProperties: falsefor each message type, so fixing this would also make the genui package follow the spec more closely.