Skip to content

fix(web_core): reject undeclared keys in v1.0 accessibility attributes and in check rules - #4436

Open
hualu00 wants to merge 2 commits into
a2ui-project:mainfrom
hualu00:fix/web-core-strict-accessibility-checks-4435
Open

hualu00 wants to merge 2 commits into
a2ui-project:mainfrom
hualu00:fix/web-core-strict-accessibility-checks-4435

Conversation

@hualu00

@hualu00 hualu00 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Problem

On protocol v1.0, PayloadValidator (and so validatePayload in @a2ui/agent) accepts a component whose @accessibility object or @checks rule carries a key the specification does not declare:

{id: 'f', component: 'TextField', label: 'Name', value: {'@path': '/name'},
 '@accessibility': {color: 'red'}}                                   // accepted
{id: 'f', component: 'TextField', label: 'Name', value: {'@path': '/name'},
 '@checks': [{condition: {'@path': '/name'}, color: 1}]}              // accepted

specification/v1_0/json/common_types.json declares both AccessibilityAttributes and CheckRule with "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 merging common_types.json across v0.9, v0.9.1 and v1.0:

  • CheckRule is closed in all three versions, but the generator's object merge copied only properties and required, so the merged schema lost the closure. A component from Catalog.fromJson resolves common_types.json#/$defs/Checkable to this shared schema.
  • AccessibilityAttributes is 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 @accessibility with it anyway.

Fixes #4435

Changes

  • scripts/generate-superset-common-types.mjs: mergeObjectSchemas keeps the merged object closed when every version closes it. A version that uses patternProperties, or an additionalProperties schema beside unevaluatedProperties: false, does not count as closed, because it admits keys that properties does not list. Regenerating changes one line: CheckRuleSchema gains .strict().
  • src/catalog/component_envelope.ts: add V10AccessibilityAttributesSchema, the shared AccessibilityAttributes schema closed with .strict().
  • src/validation/payload-validator.ts: the v1.0 envelope mixin path validates @accessibility (and the legacy bare accessibility) with the closed schema.
  • src/catalog/schema_loader.ts: a v1.0 component that composes common_types.json#/$defs/ComponentCommon gets the closed schema for its accessibility mixin.

Behavior that changes:

Payload Before After
v1.0 accessibility attributes with an undeclared key accepted rejected
Check rule with an undeclared key, component from Catalog.fromJson, v0.9 and later accepted rejected
v0.9 and v0.9.1 accessibility attributes with an undeclared key accepted accepted

The check rule change also applies before v1.0, because CheckRule is 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.ts because that schema's FunctionCall accepts any key, so a call such as {"@call": "formatText", "args": {}, "color": 1} inside @accessibility would start to pass. A test covers this.

Not changed here:

  • A component property that references common_types.json#/$defs/AccessibilityAttributes directly still accepts undeclared keys on v1.0. resolveProtocolRef in schema_loader.ts has no protocol version to choose a schema with.
  • Other v1.0 constraints that the shared schemas are looser on, such as a literal boolean 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) and yarn format:check pass locally. yarn test in typescript/agents/a2ui_agent passes (2108 passed), and the reproduction from the issue now rejects all three payloads. I did not run the Lit, Angular or React renderer tests or scripts/e2e_test.sh.

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.

…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

@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 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.

@github-actions github-actions Bot added the status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs label Nov 27, 2026
@polina-c

polina-c commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

From triage bot, analysis:

For humans

TL;DR
Case: this external PR fixes #4435 and overlaps with #4349.
Suggestion: assign Varun-S10 and add status: assigned-for-triage.

Summary:
The PR makes v1.0 validation reject undeclared keys in @accessibility and in @checks rules, as #4435 reports. It keeps CheckRule closed in the generator of the shared common types, and adds a strict v1.0 accessibility schema in component_envelope.ts.

Targeted issues:
#4435

Why flagged for triage:
This PR has no assignee.

Suggestion:

  • A small bug fix with tests: about 60 lines of code and 146 lines of tests, with no merge conflicts.
  • #4349, assigned to Varun-S10, fixes #4348, the same check rule bug for catalogs read with Catalog.fromJson, by resolving the v1.0 common types in schema_loader.ts. This PR left that approach for later. The expert decides whether to take one PR or both.
  1. Add labels: type: bug, component: core sdk, lang: typescript, status: assigned-for-triage
  2. Assign: Varun-S10
  3. Related items: fix(web_core): check v1.0 catalogs read from JSON against the v1.0 common types #4349, [BUG]: web_core's Catalog.fromJson accepts v1.0 check rules with a literal boolean condition or an extra key #4348

Reply:

From triage:

Thanks for the fix and the tests. Assigning this PR to Varun-S10, who is assigned to #4349, which also changes how v1.0 check rules are validated, to decide on it.

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/4436
For software
<a2ui>
root = TriageAnalysis(
  tldr="""Case: this external PR fixes [#4435](https://github.com/a2ui-project/a2ui/issues/4435) and overlaps with [#4349](https://github.com/a2ui-project/a2ui/pull/4349).
Suggestion: assign `Varun-S10` and add `status: assigned-for-triage`.""",
  summary="""The PR makes v1.0 validation reject undeclared keys in `@accessibility` and in `@checks` rules, as [#4435](https://github.com/a2ui-project/a2ui/issues/4435) reports. It keeps `CheckRule` closed in the [generator](https://github.com/a2ui-project/a2ui/blob/4555c8602e8b3b788b2cde9669edcf703746da4d/typescript/core/web_core/scripts/generate-superset-common-types.mjs) of the shared common types, and adds a strict v1.0 accessibility schema in [component_envelope.ts](https://github.com/a2ui-project/a2ui/blob/4555c8602e8b3b788b2cde9669edcf703746da4d/typescript/core/web_core/src/catalog/component_envelope.ts).""",
  reason="This PR has no assignee.",
  suggestion="""- A small bug fix with tests: about 60 lines of code and 146 lines of tests, with no merge conflicts.
- [#4349](https://github.com/a2ui-project/a2ui/pull/4349), assigned to `Varun-S10`, fixes [#4348](https://github.com/a2ui-project/a2ui/issues/4348), the same check rule bug for catalogs read with `Catalog.fromJson`, by resolving the v1.0 common types in [schema_loader.ts](https://github.com/a2ui-project/a2ui/blob/36725eee042da90c526f469f94246f96e16fdc35/typescript/core/web_core/src/catalog/schema_loader.ts). This PR left that approach for later. The expert decides whether to take one PR or both.""",
  reply="""Thanks for the fix and the tests. Assigning this PR to `Varun-S10`, who is assigned to [#4349](https://github.com/a2ui-project/a2ui/pull/4349), which also changes how v1.0 check rules are validated, to decide on it.""",
  added_labels=["type: bug", "component: core sdk", "lang: typescript", "status: assigned-for-triage"],
  new_assignees=["Varun-S10"],
  targeted_issues=[4435],
  related_items=[4349, 4348]
)
</a2ui>

This analysis does not change after taking the later submitted comments into account: comment from hualu00.

This analysis is auto-created to help humans to triage this item. Please, do not treat it as a team decision.

@hualu00

hualu00 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

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 componentCommonMixinProperties, the changelog and payload-validator.test.ts, so there is overlap to reconcile. If #4349 lands first, I'm happy to rebase this PR onto it and reduce it to the two points above. I have not run #4349 locally, so please correct me if I misread it.

@Varun-S10

Copy link
Copy Markdown
Collaborator

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.
Hi @gspencergoog, could you please take a look?

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.

validatePayload accepts unknown keys in @accessibility and @checks rules (v1.0)

3 participants