Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the A2UI protocol documentation to allow 'Child', 'DataBinding', and 'FunctionCall' as external $ref targets, and significantly enhances the test suite in 'run_tests.py' by implementing robust, recursive validation for JSON Schema subschemas. Specifically, it adds recursive walks to validate property names (ensuring they are valid UAX #31 identifiers) and $ref targets (ensuring they conform to the protocol's restricted target rules), backed by comprehensive synthetic test cases. Feedback on the changes suggests defensively validating that the loaded catalog is a JSON dictionary in 'validate_catalogs_ref_targets' to prevent potential AttributeError crashes if a malformed catalog parses as a list or primitive.
4d77ea1 to
c58a023
Compare
c58a023 to
f512a82
Compare
|
Hi @uny, I have reviewed and verified the changes. Thank you for your contribution. Hi @gspencergoog, I would like to escalate this PR. Could you please take a look? |
|
Thanks for fixing this! Please separate this from #2707 for easier review. Since we're not inclined to include the entire ad-hoc JSON Schema AST traverser from the other change, this change can be reduced to just looking through |
d73d0d8 to
cd013f4
Compare
… targets
Rule 3 of the catalog schema rules ("Restricted `$ref` Targets") enumerates
the common_types.json schemas an external `$ref` may target. The reference
catalog at catalogs/basic/v1/catalog.json targets three schemas that are not
on that list: `Child` (5 occurrences), `DataBinding` (2) and `FunctionCall`
(1). The list was written when the catalog used `ComponentId`; the three
names arrived later without the list being updated, so an implementer who
enforces rule 3 as written cannot load the reference catalog.
Add the three names to the list, and add `validate_catalogs_ref_targets` to
the test harness so the document and the shipped catalogs cannot drift apart
again: every `$ref` under `components`, `functions` and `$defs` is collected
(skipping annotation and literal-data keys, while a declared property named
`metadata` stays in scope), a local target must name a component or function
the catalog declares, and an external target must be one of the listed
schemas.
Fixes a2ui-project#2706.
cd013f4 to
d6ba12e
Compare
|
Thanks for the review. I've separated this from #2707 and rebased it onto
I'll rework #2707 separately along the lines of your |
Description
Rule 3 of the catalog schema rules ("Restricted
$refTargets",docs/a2ui_protocol.md565–579) enumerates thecommon_types.jsonschemas an external$refmay target.catalogs/basic/v1/catalog.jsonreferences three schemas that are not on that list:ChildCard.child,Tabs.tabs[].child,Modal.trigger,Modal.content,Button.childDataBindingIcon.name,openUrl.args.urlFunctionCallopenUrl.args.urlThe list was written in #1629 when the catalog used
ComponentId;DataBinding/FunctionCallarrived with #1944 and #2070, andChildreplacedComponentIdin #2056, without the list being updated. An implementer who enforces rule 3 as written cannot load the reference catalog; one who loads it is not enforcing rule 3.Childresolves toComponentId, which is listed, but rule 3 enumerates$reftargets, so a validator checks the target name, not what it resolves to — and the SDKs' inference formats match on the nameChildas well.This PR:
Child,DataBindingandFunctionCallto the rule 3 list;validate_catalogs_ref_targetstotest/run_tests.py, which enforces rule 3 over the two catalogs the harness already checks (catalogs/basic/v1/catalog.jsonandtest/testing_catalog.json): every$refundercomponents,functionsand$defsis collected, skipping annotation and literal-data keys (metadata,examples,const,default,enum,description) while a declared property namedmetadatastays in scope; a local target must name a component or function the catalog declares, and an external target must be one of the listedcommon_types.json#/$defs/*schemas.Fixes #2706.
Reproduction
No workflow runs
run_tests.py, so:main: 167 passed.ChildfromALLOWED_EXTERNAL_REF_TARGETS):catalogs/basic/v1/catalog.jsonfails on exactly its fiveChildreferences.Pre-launch Checklist
One time:
For this PR:
specification/specification/v1_0only;python3 run_tests.py,pyink --checkandprettier --checkpass🤖 Generated with Claude Code