Repository navigation
Conversation
…s and in check rules PayloadValidator accepted a v1.0 component whose `@accessibility` object or `@checks` rule carried a key the specification does not declare, although `AccessibilityAttributes` (v1.0) and `CheckRule` (every version) set `additionalProperties: false`. - The superset common types generator dropped the closure of an object definition when merging it across versions. It now keeps the merged object closed when every version closes it, which makes the shared `CheckRule` schema strict. - `AccessibilityAttributes` is open before v1.0, so the shared schema stays open. The v1.0 envelope mixin path of PayloadValidator, and the `ComponentCommon` mixin of a v1.0 catalog loaded with `Catalog.fromJson`, now use a closed copy of it. Fixes a2ui-project#4435
There was a problem hiding this comment.
Code Review
This pull request introduces strict validation for check rules and v1.0 accessibility attributes by rejecting undeclared keys. It defines a strict V10AccessibilityAttributesSchema to enforce this restriction for v1.0 while keeping earlier versions open, and updates CheckRuleSchema to be strict. Additionally, the schema generation script is updated to handle closed object schemas correctly when merging them, and comprehensive unit tests are added to verify these changes. I have no further feedback to provide.
|
From triage bot, analysis: For humansTL;DR Summary: Targeted issues: Why flagged for triage: Suggestion:
Reply:
To adjust the analysis and apply its suggestion, open it in the hosted triage UI, or run in your a2ui checkout: tools/internal/triage/triage_ui.sh https://github.com/a2ui-project/a2ui/pull/4436For softwareThis analysis does not change after taking the later submitted comments into account: comment from This analysis is auto-created to help humans to triage this item. Please, do not treat it as a team decision. |
|
Thanks for the triage. I missed #4348 and #4349 when I picked up #4435, sorry for the overlap. From reading the diff of #4349 (which includes #4347's commit), the two PRs relate like this:
Both PRs edit |
|
Hi @hualu00, 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. |
Problem
On protocol v1.0,
PayloadValidator(and sovalidatePayloadin@a2ui/agent) accepts a component whose@accessibilityobject or@checksrule carries a key the specification does not declare:specification/v1_0/json/common_types.jsondeclares bothAccessibilityAttributesandCheckRulewith"additionalProperties": false, so both payloads are invalid.The two cases have different causes. Both come from the shared common types in
src/types/common-types.ts, which are generated by mergingcommon_types.jsonacross v0.9, v0.9.1 and v1.0:CheckRuleis closed in all three versions, but the generator's object merge copied onlypropertiesandrequired, so the merged schema lost the closure. A component fromCatalog.fromJsonresolvescommon_types.json#/$defs/Checkableto this shared schema.AccessibilityAttributesis open in v0.9 and v0.9.1 and closed only in v1.0, so the merged schema has to stay open. The v1.0 code paths validated@accessibilitywith it anyway.Fixes #4435
Changes
scripts/generate-superset-common-types.mjs:mergeObjectSchemaskeeps the merged object closed when every version closes it. A version that usespatternProperties, or anadditionalPropertiesschema besideunevaluatedProperties: false, does not count as closed, because it admits keys thatpropertiesdoes not list. Regenerating changes one line:CheckRuleSchemagains.strict().src/catalog/component_envelope.ts: addV10AccessibilityAttributesSchema, the sharedAccessibilityAttributesschema closed with.strict().src/validation/payload-validator.ts: the v1.0 envelope mixin path validates@accessibility(and the legacy bareaccessibility) with the closed schema.src/catalog/schema_loader.ts: a v1.0 component that composescommon_types.json#/$defs/ComponentCommongets the closed schema for its accessibility mixin.Behavior that changes:
Catalog.fromJson, v0.9 and laterThe check rule change also applies before v1.0, because
CheckRuleis closed in v0.9 and v0.9.1 too. The catalogs defined in code already rejected such a rule.I closed the shared accessibility schema instead of switching to the one in
src/v1_0/schema/common-types.tsbecause that schema'sFunctionCallaccepts any key, so a call such as{"@call": "formatText", "args": {}, "color": 1}inside@accessibilitywould start to pass. A test covers this.Not changed here:
common_types.json#/$defs/AccessibilityAttributesdirectly still accepts undeclared keys on v1.0.resolveProtocolRefinschema_loader.tshas no protocol version to choose a schema with.CheckRule.condition, are still accepted. Enforcing them means resolving common types by protocol version in the loader, which also affects the legacy bare mixin keys (Remove legacy bare-key fallback for v1.0 component envelope fields #4082), so I left it for a separate discussion.Verification: in
typescript/core/web_core,yarn test(1672 passed, conformance included),node --test scripts/generate-superset-common-types.test.mjs,yarn lint(no errors) andyarn format:checkpass locally.yarn testintypescript/agents/a2ui_agentpasses (2108 passed), and the reproduction from the issue now rejects all three payloads. I did not run the Lit, Angular or React renderer tests orscripts/e2e_test.sh.Pre-launch Checklist
One time:
For this PR:
If you need help, consider asking for advice on the discussion board.