Skip to content

fix(web_core): accept @ mixin keys as property names in Catalog.fromJson - #4558

Open
gspencergoog wants to merge 2 commits into
a2ui-project:mainfrom
gspencergoog:fix-something/20261202-issue-4555
Open

gspencergoog wants to merge 2 commits into
a2ui-project:mainfrom
gspencergoog:fix-something/20261202-issue-4555

Conversation

@gspencergoog

Copy link
Copy Markdown
Collaborator

Architecture & Contract Brief

  • Root cause: In @a2ui/web_core, parseCatalogComponents() runs the v1.0 identifier check on every key under a component's properties. A flattened validation schema declares the envelope mixins there under their wire names (@checks, @accessibility, @metadata, @catalogId), which are not UAX 31 identifiers, so Catalog.fromJson(catalog.validationSchema, '1.0') threw A2uiCatalogError.
  • Contract impact: Catalog.fromJson() and a2ui lint accept documents they used to reject, and reject nothing new. Exactly those four names are exempt, by name. No exported symbol, schema, or specification text changes.
  • Verification: A new unit test and a new shared conformance case fail before the fix with the error from the issue and pass after it. Python and Dart core pass both new cases unchanged.
  • Key judgment call: The exemption matches by name only, as Python Catalog.from_json and Dart Catalog.fromJson already do. One consequence needs your decision and is described under Impact & Risks: PayloadValidator validates a declared @accessibility or @checks against the schema the catalog declares.
  • Not verified locally: The Swift conformance harness edit. The Swift package does not build on the Linux host used for this change, so the Swift CI job is its only compile and test run.

Fixes #4555

Summary

Let Catalog.fromJson() in @a2ui/web_core load a v1.0 catalog document that declares the @-prefixed envelope mixin keys as component properties, which is what Catalog.validationSchema produces. The same exemption is applied to the two other copies of the property-name check that lacked it: a2ui lint in dart/a2ui_cli and the Swift conformance harness.

Reviewer Focus

  • typescript/core/web_core/src/catalog/schema_loader.ts: the one-line skip in parseCatalogComponents(). Only the identifier check changes. The conversion and mixin-layout code after it already treats these keys as the standard mixins.
  • swift/core/Tests/A2UIConformanceTests/CatalogConformanceTests.swift: test-only code that was not compiled locally (see the brief above).
  • conformance/core/catalog.yaml: the accepting case uses minimal typed schemas for the four keys, so it checks the name rule and nothing about the mixins' shapes.

Changes

  • schema_loader.ts: skip keys in AT_COMPONENT_MIXIN_KEYS before assertUax31Identifier() in the properties loop of parseCatalogComponents(). Any other @ name is still rejected.
  • schema_loader.test.ts: a test that reloads the v1 basic catalog's validationSchema with Catalog.fromJson() and compares the reloaded catalog's validationSchema with the original.
  • conformance/core/catalog.yaml: test_v10_uax31_standard_mixin_property_names_allowed (a component declaring the four keys loads) and test_v10_uax31_other_at_property_name_rejected (@custom fails with CatalogError), both tagged F-CORE-09.
  • dart/a2ui_cli/lib/src/analyzer/catalog_lint.dart: the v1.0 property-name lint skips the same four keys. The package's parity test compares lintCatalog() with Catalog.fromJson for every from_json conformance case and failed on the new accepting case.
  • CatalogConformanceTests.swift: the harness's own property-name check skips the same four keys. Swift product code has no catalog identifier check.
  • CHANGELOG.md entries for @a2ui/web_core and a2ui_cli.

Impact & Risks

  • No breaking changes, no new dependencies, no version bumps.
  • A catalog document can now declare a property named @checks, @accessibility, @metadata, or @catalogId and load in web_core. That was already true in Python and Dart, and for web_core catalogs defined in code.
  • When a component schema declares @accessibility or @checks, PayloadValidator in web_core validates the value against the declared schema, not against the standard AccessibilityAttributes or CheckRule schema. This is existing behavior for catalogs defined in code, and this PR makes it reachable from a JSON catalog. For example, a JSON catalog that declares "@accessibility": {"type": "boolean"} now loads, accepts "@accessibility": true, and rejects {"label": "L"}. Before this PR that catalog failed to load. Python rejects true for the same catalog, because its validator always applies the standard schemas. A schema produced by Catalog.validationSchema declares the standard shapes, so it is not affected. This PR does not change PayloadValidator. @catalogId and @metadata are still checked against the standard rules.
  • @a2ui/embed/mcp/express in the open PR feat(embed): add @a2ui/embed/mcp/express for host-authored Express #4504 carries a workaround for this issue. This PR does not touch it.

Testing

  1. web_core, before the loader fix: node --test dist/src/catalog/schema_loader.test.js failed the new test with Invalid UAX #31 property identifier: '@checks' in component 'Button', and node tests/conformance/conformance_test.mjs reported 853 of 854 with the accepting case failing.
  2. web_core, after: the unit file passes 32 of 32, the conformance runner 854 of 854, and yarn workspace @a2ui/web_core test passes 1709 tests. yarn workspace @a2ui/web_core lint reports 0 errors.
  3. Python: uv run pytest python/a2ui_core/tests/test_conformance.py -q passes (862 passed), with no Python change.
  4. Dart core: dart test test/conformance in dart/a2ui_core passes (875 passed), with no change to a2ui_core.
  5. Dart CLI: before the lint fix, dart test test/lint_command_test.dart failed the parity test for the accepting case with four invalid_identifier findings. After it, dart test passes (115 passed) and dart analyze reports no issues.
  6. Swift: swift format lint --strict and a syntax-only parse pass on the edited file. The test target was not built or run locally.
  7. uv run --project conformance python conformance/scripts/check_feature_coverage.py --static reports 0 findings. Prettier 3.8.4 and ./scripts/fix_licenses.py --check pass.

Pre-launch Checklist

One time:

For this PR:

  • I have updated the relevant CHANGELOG.md file.
  • I updated/added relevant documentation. (Not applicable: no documented behavior or public API changed.)
  • My code changes (if any) have tests.
  • If my branch is on a fork, I have verified that scripts/e2e_test.sh passes. (Not run: the change is confined to catalog loading and lint checks, covered by the unit and conformance suites above.)

A flattened v1.0 validation schema declares the component envelope
mixins (checks, accessibility, metadata, and catalogId, under their
@-prefixed wire names) in a component's properties.
parseCatalogComponents() ran the UAX 31 identifier check on those keys,
so Catalog.fromJson(catalog.validationSchema, '1.0') threw
A2uiCatalogError.

Skip the four mixin keys before the identifier check, as Python and Dart
core already do. Two shared conformance cases pin the rule: the four keys
load, and any other @-prefixed name is still rejected. They showed that
a2ui lint in dart/a2ui_cli and the Swift conformance harness had their
own copies of the check without the exemption, so both get it too.

Fixes a2ui-project#4555

@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 updates the catalog validation logic across Dart, Swift, and TypeScript implementations to allow the @-prefixed component envelope mixin keys (@CatalogId, @metadata, @accessibility, and @Checks) to be declared as component properties in v1.0 catalogs. This ensures that flattened validation schemas, which declare these mixins as properties under their wire names, can be successfully loaded and validated without failing UAX #31 identifier checks. Corresponding tests and changelog entries have been added. I have no feedback to provide as there are no review comments.

@gspencergoog
gspencergoog marked this pull request as ready for review December 3, 2026 17:27

@josemontespg josemontespg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Thanks for the quick fix!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web_core: Catalog.fromJson() rejects v1.0 @-prefixed standard mixins from Catalog.validationSchema

2 participants