Skip to content

fix(web_core): accept only @path and @call in v1.0 bindings and calls - #4347

Open
retz8 wants to merge 4 commits into
a2ui-project:mainfrom
retz8:fix/web-core-v1-bare-path-call
Open

retz8 wants to merge 4 commits into
a2ui-project:mainfrom
retz8:fix/web-core-v1-bare-path-call

Conversation

@retz8

@retz8 retz8 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Problem

In web_core, a v1.0 payload that writes a binding or a call with v0.9's keys, {"path": ...} or {"call": ...}, passes PayloadValidator and MessageProcessor, in strict mode too. At v1.0 DataContext reads only @path and @call, so the surface renders the object itself. #4346 has the mechanism.

This PR fixes it for catalogs built on web_core's v1.0 schemas, such as the basic catalog and @a2ui/catalog-mcp. Catalogs loaded with Catalog.fromJson, which validate against the cross-version superset, are left for their own change. A v1.0 producer that still writes plain path and call now gets a validation error, so the CHANGELOG entry marks this as breaking. @a2ui/agent's renderer function calls and the Python Atom compiler already write the @ keys at v1.0.

Part of #4346.

Changes

@a2ui/web_core: src/v1_0/scripts/generate-schemas.mjs no longer replaces the v1.0 common types' DataBinding, FunctionCommon and IndexSystemFunction with hand-written schemas that take both spellings. It emits them from specification/v1_0/json/common_types.json as written: @path and @call are required, and a DataBinding takes no other key, as its additionalProperties: false says and as the Python core's v1.0 DataBinding does. The generator's literal-object branch of DynamicValue excluded path and call as well as @path and @call. It now excludes only the @ keys, as the common types' not: {anyOf: [{required: ["@path"]}, {required: ["@call"]}]} does. Without that, a plain object with path or call keys, which test_plain_object_with_literal_path_and_call and the spec's dynamic_value_validation.json accept, would match no branch. src/v1_0/schema/common-types.ts is regenerated.

Unchanged: the superset in src/types/common-types.ts, which Catalog.fromJson catalogs validate against; DataContext; and the RPC handler, which still falls back to call when @call is absent.

Changed tests. Each wrote v1.0 data with plain path or call and relied on the old schemas accepting them:

  • web_core processing/message-processor.test.ts: 11 callRendererFunction fixtures move from call to @call. The v1.0 spec requires @call there, and @a2ui/agent's renderer function calls and the Python Atom compiler write it at v1.0. One of them is the case that expects a call without catalogId to be refused. With call it would now also be refused for the missing @call, so it moves to keep testing what it says.
  • Angular v1_0.spec.ts: the v1.0 TextField's value and its check's condition move to @path.
  • catalog-mcp functions/callMcpTool.test.ts: the schema test of bindings in name and arguments moves to @path. The test of resolving those bindings called the invoker directly with v0.9 bindings, which catalog-mcp's own resolver read. It now calls callMcpTool through a v1.0 DataContext with @path bindings, as a v1.0 surface does. createTestDataContext takes an optional protocol version for it. The comment above callMcpTool.ts's imports no longer says the v1.0 schemas accept the v0.9 keys.
  • @a2ui/agent utils/renderer-function-call-validation.test.ts: a callFunction written with call is now refused by the message schema ("'@call' is a required property") before the agent's own check ("is missing a string '@call' field"), so the case expects that message.

The moved web_core and catalog-mcp tests pass on main too.

Tests

  • New: PayloadValidator rejects v0.9's bare path and call keys as v1.0 dynamic values in catalogs/basic/v1/basic_catalog_elements.test.ts. On main it fails with Missing expected exception (A2uiValidationError): expected {"path":"/name"} to be rejected. Its last assertion, a literal DynamicValue holding path and call keys, fails when the generator's DynamicValue branch is put back as it was.
  • With the issue's reproduction, the built-in v1.0 catalog rejects {"path"} and {"call"}, and @path, @call and v0.9 resolve as before. The Catalog.fromJson lines are unchanged.

On this branch:

  • @a2ui/web_core: test 1659/1659; tests/conformance/conformance_test.mjs 830/830 passed, 1072 skipped, as on main; ESLint 0 errors, and 822 warnings as on main
  • @a2ui/agent: 2070 passed, 441 skipped
  • @a2ui/catalog-mcp: test:node 196/196, test:karma 227/227, test:types
  • @a2ui/react: test:unit 540 passed, 1 skipped
  • @a2ui/lit: test:unit 161 passed
  • @a2ui/catalog-vegachart 26/26, @a2ui/markdown-it, widget-builder 32/32, @a2ui/lit-explorer, @a2ui/react-explorer
  • ./scripts/fix_format.sh --check: Prettier and pyink pass. Its Dart step fails on main too, since fix(dart/core): report unknown envelope keys at their paths #4197, in dart/a2ui_core/lib/src/processing/processor.dart and test/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. Instead, the changed spec's v1.0 TextField was run through web_core's MessageProcessor on this branch: as it was, it is rejected, and with @path it is accepted. Also not run: scripts/e2e_test.sh, and fix_licenses.py (no new files).

Pre-launch Checklist

One time:

For this PR:

  • I have updated the relevant CHANGELOG.md file.
  • I updated/added relevant documentation.
  • My code changes (if any) have tests.
  • If my branch is on a fork, I have verified that scripts/e2e_test.sh passes.

If you need help, consider asking for advice on the discussion board.

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.

@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 introduces a breaking change for v1.0 schemas (including DataBinding, FunctionCommon, and IndexSystemFunction) by strictly requiring the '@path' and '@call' keys and rejecting the v0.9 'path' and 'call' keys. Corresponding updates have been made to the schema generator, tests, and test configurations. The review feedback highlights that helper functions 'isArgumentsCall' and 'resolveToolArguments' in 'callMcpTool.ts' must be updated to support '@call' to avoid treating v1.0 function calls as plain records, and suggests adding a test case to verify this behavior.

Comment on lines +127 to +129
// The argument schemas come from the v1.0 entry point, so a v1.0 payload binding a tool argument
// with `@path` or `@call` validates when the surface is processed. The message types stay the v0.9
// ones, which describe every payload a tool result may carry.

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.

high

With the transition to strictly requiring @call and @path in v1.0, isArgumentsCall and resolveToolArguments (defined further down in this file) need to be updated to support @call.

Currently, isArgumentsCall only checks for call, args, and returnType:

function isArgumentsCall(value: unknown): value is FunctionCall {
  return (
    isFunctionCall(value) &&
    Object.keys(value).every(key => key === 'call' || key === 'args' || key === 'returnType')
  );
}

Because @call is not in that list, any v1.0 function call passed as the entire arguments object will not be recognized as a function call, and resolveToolArguments will treat it as a plain record instead of executing it.

Additionally, resolveToolArguments needs to pass @call to resolveDynamicValue:

function resolveToolArguments(
  value: FunctionCall | Record<string, unknown>,
  context: DataContext,
): unknown {
  if (!isArgumentsCall(value)) {
    return resolveDynamicRecord(value, context);
  }
  return context.resolveDynamicValue({
    '@call': value['@call'] ?? value.call,
    'args': value.args ?? {},
    'returnType': value.returnType ?? 'any',
  } as any);
}

Please update both functions to fully support @call for v1.0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This predates this PR: main behaves the same. On a v1.0 surface, web_core's DataContext resolves an @call in arguments before callMcpTool runs, so the tool receives the call's result. Only a direct catalog.invoker call with an unresolved v1.0 call reaches isArgumentsCall. The suggested change would not catch that case either: isFunctionCall in dynamic-values.ts requires a string call, so {"@call": ...} still fails it. Making catalog-mcp's resolver read the v1.0 keys is a separate change, noted in #4346, so I've kept it out of this PR.

Comment on lines 252 to 261
it('parses dynamic data bindings in name and arguments', () => {
const parsed = CallMcpToolApi.schema.parse({
name: {path: '/selectedTool'},
arguments: {city: {path: '/user/city'}, count: 10},
name: {'@path': '/selectedTool'},
arguments: {city: {'@path': '/user/city'}, count: 10},
});
assert.deepStrictEqual(parsed, {
name: {path: '/selectedTool'},
arguments: {city: {path: '/user/city'}, count: 10},
name: {'@path': '/selectedTool'},
arguments: {city: {'@path': '/user/city'}, count: 10},
});
});

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.

medium

Since we are strictly using @call and @path in v1.0, we should also add a test case to verify that a v1.0 function call passed as the entire arguments object is parsed correctly. Currently, there is only a v0.9 test case for this (takes the result of a function call as the arguments, without resolving it again).

    it('parses dynamic data bindings in name and arguments', () => {
      const parsed = CallMcpToolApi.schema.parse({
        name: {'@path': '/selectedTool'},
        arguments: {city: {'@path': '/user/city'}, count: 10},
      });
      assert.deepStrictEqual(parsed, {
        name: {'@path': '/selectedTool'},
        arguments: {city: {'@path': '/user/city'}, count: 10},
      });
    });

    it('parses a v1.0 function call as the whole arguments object', () => {
      const call = {'@call': 'transformData', args: {jmespath: '{path: @}', data: {path: '/dir'}}};
      const parsed = CallMcpToolApi.schema.parse({name: 'list_directory', arguments: call});
      assert.deepStrictEqual(parsed, {name: 'list_directory', arguments: call});
    });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test already passes on this branch, because {"@call": ...} parses as a plain record of tool arguments, so it wouldn't show that the call is recognized. A test for that belongs with the resolver change noted in #4346.

@Varun-S10

Copy link
Copy Markdown
Collaborator

Hi @retz8, Thank you for raising the pr to fix the issue. We have verified the pr and it does resolve the issue. I will escalate this to team to review. Thank you for your patience and understanding.
Hi @gspencergoog, could you please take a look?

@Varun-S10 Varun-S10 added status: needs review and removed status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs labels Nov 23, 2026
…e-path-call

# Conflicts:
#	typescript/core/web_core/CHANGELOG.md

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants