Repository navigation
Conversation
The v1.0 schema generator replaced the common types' DataBinding,
FunctionCommon and IndexSystemFunction with hand-written schemas that
took v0.9's bare `path` or `call` beside `@path` or `@call`. The v1.0
common types allow only the `@` keys, and DataContext reads only them at
v1.0, so a v1.0 payload written with `{"path": ...}` or `{"call": ...}`
passed PayloadValidator and MessageProcessor, in strict mode too, and
was then drawn as the literal object.
The generator now emits the three definitions from the v1.0 common
types as written: `@path` and `@call` are required, and a DataBinding
takes no other key. The literal branch of DynamicValue excludes only
`@path` and `@call`, as the common types define it, so a plain object
with `path` or `call` keys stays a literal.
Catalogs loaded with Catalog.fromJson resolve their common type
references in the cross-version superset in types/common-types.ts, which
still takes both spellings; that is left for its own change.
Tests that sent a v1.0 message with the bare keys move to the `@` keys:
web_core's callRendererFunction fixtures, the Angular v1.0 rendering
spec, and two catalog-mcp callMcpTool tests, one of which now calls the
tool through a v1.0 DataContext. The comment above callMcpTool's
imports no longer says the v1.0 schemas take the v0.9 keys. The
@a2ui/agent case for a callFunction written with `call` expects the
message schema's error, which now reports it before the agent's own
check.
…mmon types Catalog.fromJson resolved every common_types.json reference in types/common-types.ts, the runtime superset of v0.9 and v1.0, whatever the catalog's version. Its CheckRule takes v0.9's literal boolean condition and any key, so a v1.0 catalog read from JSON, which is how @a2ui/agent builds every catalog, accepted check rules that the built-in v1.0 basic catalog and the v1.0 common types refuse. The loader now resolves a v1.0 catalog's references, and the ComponentCommon its components compose, in v1_0/schema/common-types.ts. Other catalogs keep the superset. The superset's FunctionCall was strict, and the v1.0 one took any key, since jsonSchemaToZod drops the unevaluatedProperties: false that closes FunctionCommon and the catalog function. The v1.0 generator now refuses any key other than those two declare: @call and catalogId from FunctionCommon, and @call and args, which catalog_definition.json limits a catalog function's properties to. This keeps test_v10_published_basic_catalog_rejects_function_call_extra_key passing, and the built-in catalog refuses those keys too. The FunctionCall type is unchanged. Tests that wrote a v1.0 check rule with a literal boolean condition move to a @path binding. Two schema_loader tests expected a v1.0 catalog's components to declare the bare checks and accessibility. They now expect @Checks and @accessibility, and the bare keys are still read as the legacy mixins. In @a2ui/agent, a callFunction with an extra key is now refused by the message schema before the agent's own check, so the case expects the schema's message.
There was a problem hiding this comment.
Code Review
This pull request introduces breaking changes to strictly align v1.0 schemas (such as DataBinding, FunctionCommon, IndexSystemFunction, and FunctionCall) with the v1.0 common types specification. Support for legacy v0.9 keys (path and call) has been removed in v1.0 contexts, enforcing the use of @path and @call. Additionally, strict validation has been added to reject unrecognized keys in function calls and literal boolean conditions in check rules. The schema loader, payload validator, message processor, and corresponding tests have been updated to enforce these new validation constraints. I have no feedback to provide as there are no review comments.
|
Hi @retz8, Thank you for raising the issue. We have reproduced the issue and we appreciate you have raised pr to fix the issue. The pr will be reviewed. Thank you for your patience and understanding. |
…e-path-call # Conflicts: # typescript/core/web_core/CHANGELOG.md
…on-v1-common-types # Conflicts: # typescript/core/web_core/CHANGELOG.md
…e-path-call # Conflicts: # typescript/core/web_core/CHANGELOG.md
…son-v1-common-types # Conflicts: # typescript/core/web_core/CHANGELOG.md # typescript/core/web_core/src/catalog/schema_loader.ts
Problem
In web_core, a v1.0 catalog loaded with
Catalog.fromJsonresolves itscommon_types.jsonreferences in the runtime superset of v0.9 and v1.0. So it accepts a check rule whoseconditionis a literal boolean, or that has a keyCheckRuledoes not define, which the built-in v1.0 basic catalog rejects.@a2ui/agentbuilds every catalog withCatalog.fromJson, so itsvalidatePayloadaccepts these rules, while the Python agent SDK'svalidate_payloadrejects them. #4348 has the mechanism.With this PR, a v1.0 catalog read from JSON is checked against the v1.0 common types, as the built-in catalog is. A v1.0 producer that writes such a check rule, or a function call with a key other than
@call,catalogIdandargs, now gets a validation error, so the CHANGELOG entry marks this as breaking.Stacked on #4347, because the function call change edits the v1.0 generator next to #4347's change. The first commit is #4347's and the second is this change. Once #4347 merges, the diff is only the second commit. On top of #4347, a v1.0 catalog read from JSON also rejects v0.9's bare
pathandcall, which #4346 left open.Fixes #4348. Part of #4346.
Changes
@a2ui/web_core:src/catalog/schema_loader.ts: for a v1.0 catalog,parseCatalogSchemarecords the v1.0 common types (src/v1_0/schema/common-types.ts), andresolveProtocolReflooks references up there. This covers a property's$refand anallOfmixin such asCheckable. The record is aWeakMapkeyed by the parsed document, which every converter already receives asrootDoc, so no converter's signature changes.componentCommonMixinPropertiestakes the v1.0ComponentCommonfor a v1.0 catalog. v0.9 catalogs keep the superset.src/v1_0/scripts/generate-schemas.mjs: the v1.0FunctionCallrejects any key other than@call,catalogIdandargs.FunctionCall'sallOf: [FunctionCommon, <catalog function>]withunevaluatedProperties: false, which jsonSchemaToZod drops, so the generated schema took any key.FunctionCommon's properties, andFunctionCallValidationSchemaincatalog_definition.json, which limits a catalog function's properties to@callandargs.@a2ui/agentchecks acallRendererFunctionagainst the same three keys (CALL_KEYSinsrc/utils/renderer-state.ts).test_v10_published_basic_catalog_rejects_function_call_extra_key. The superset's strictFunctionCallwas what rejected the extra key for a catalog read from JSON, and the built-in catalog accepted it.superRefinethat reports the extra keys asunrecognized_keys, as.strict()does, so the message is the one the superset gave ("Unrecognized key(s) in object: 'bogus'"). A.strict()object would also give the exportedFunctionCalltype, which infers asanytoday, a precise shape, and tsc then rejects 28 places that rely on the loose type, mostly test fixtures. WithsuperRefinethe type stays as it was.src/v1_0/schema/common-types.tsis regenerated.Unchanged:
src/types/common-types.ts. v0.9 catalogs read from JSON still use it, and so doesPayloadValidator's check of the accessibility and metadata mixins.checksandaccessibilityon a v1.0 component are still read. A barecheckscounts as@checkswhen the component declares@checks, as in the built-in catalog.Changed tests. Each relied on what this PR changes:
catalog/schema_loader.test.ts:conditionin a v1.0 check rule move to@pathbindings.resolves an external mixin written as a relative referenceexpected the v1.0Checkableto add a barechecks. It now expects@checks.lets a component override a property its mixins and local definitions declarelisted the barechecksandaccessibilityamong the mixin keys. The v1.0 mixins declare only@checksand@accessibility, so the component's ownchecksnow comes after its other properties.processing/message-processor.test.ts(three tests) andvalidation/payload-validator.test.ts(two tests): v1.0 check rules withcondition: trueorfalsemove to@pathbindings. The test that evaluates a rule binds/validtofalsein the data model.@a2ui/agentutils/renderer-function-call-validation.test.ts: acallFunctionwith an extra key is now refused by the message schema ("Unrecognized key(s) in object: 'bogus' at 'callRendererFunction.callFunction'") before the agent's own check ("has unrecognized field 'bogus' on callFunction"). The case expects the schema's message.The moved fixtures pass without this PR's source changes too. Of the changed tests, only the key list fails without them.
Tests
checks a v1.0 catalog's check rules against the v1.0 common typesincatalog/schema_loader.test.ts. Without the loader change it fails withMissing expected exception (A2uiValidationError): expected {"condition":true} to be rejected. Its last part checks that a v0.9 catalog read from JSON still accepts a literal booleancondition.PayloadValidator rejects a v1.0 function call holding a key no function declaresincatalogs/basic/v1/basic_catalog_elements.test.ts. Without the generator change it fails withMissing expected exception., and conformance failstest_v10_published_basic_catalog_rejects_function_call_extra_key.bogus, and accept the counter-cases. The v0.9 line is unchanged.@a2ui/agent'svalidatePayloadrejects the two check rules and accepts the valid one.On this branch:
@a2ui/web_core:test1661/1661;tests/conformance/conformance_test.mjs830/830 passed, 1072 skipped; ESLint 0 errors and 822 warnings, as onmain@a2ui/agent: 2070 passed, 441 skipped@a2ui/catalog-mcp:test:node196/196,test:karma227/227,test:types@a2ui/react:test:unit540 passed, 1 skipped@a2ui/lit:test:unit161 passed@a2ui/catalog-vegachart,@a2ui/markdown-it,widget-builder,@a2ui/lit-explorer,@a2ui/react-explorer:testpasses./scripts/fix_format.sh --check: Prettier and pyink pass. Its Dart step fails onmaintoo, since fix(dart/core): report unknown envelope keys at their paths #4197, indart/a2ui_core/lib/src/processing/processor.dartandtest/processor_test.dart, which this PR does not touch.Not run:
@a2ui/angular, whose Angular 22 CLI needs a newer Node than the one here;scripts/e2e_test.sh; andfix_licenses.py(no new files).Pre-launch Checklist
One time:
For this PR:
If you need help, consider asking for advice on the discussion board.