Skip to content

fix(core): fail checks whose result has a non-boolean valid (#3175) - #4395

Open
oyobbeb wants to merge 2 commits into
a2ui-project:mainfrom
oyobbeb:fix/check-non-boolean-valid
Open

oyobbeb wants to merge 2 commits into
a2ui-project:mainfrom
oyobbeb:fix/check-non-boolean-valid

Conversation

@oyobbeb

@oyobbeb oyobbeb commented Nov 24, 2026 •

Copy link
Copy Markdown

Problem

A check rule passes in TypeScript and Python when its condition resolves to an object whose valid member is not a boolean, while Dart and Swift fail it. The spec says a check condition evaluates to a boolean or a ValidationResult, whose valid is a boolean.

  1. TypeScript reads the result with Boolean(rec.valid) in extractValidationResult, so {"valid": "true"} passes, and so does {"valid": "false"}.
  2. Python validates the result with pydantic in _process_rule_val, which reads strings such as "true" and "yes" as True.
  3. Dart reads map['valid'] == true in validityOf, and Swift reads only a boolean valid in makePathBoundCheck, so both fail these checks.

#3850 fixed the and, or and not part of #3175 and its docs part, but no shared conformance case pins the and, or and not behavior. The check rule part is still open. The issue says TypeScript already fails these checks, but at the time it also used Boolean(rec.valid).

Fixes #3175

Changes

  1. TypeScript: a check passes only when valid is true.
  2. Python: a valid that is not True is read as False before pydantic validates the result.
  3. Conformance: test_validation_result_non_boolean_valid_fails in conformance/core/validation_result.yaml pins the check rule behavior for all four SDKs. Three cases in conformance/core/functions.yaml (test_evaluate_function_and_non_boolean_valid_operand and its or and not siblings) pin the and, or and not behavior that feat(core): unify DynamicBoolean coercion across core SDKs #3850 fixed, which no shared case covered (item 3 of Cross-platform misalignment on v1.0 ValidationResult truthiness and non-boolean 'valid' fields #3175).
  4. CHANGELOG entries for web_core and a2ui_core, marked as breaking because a check that passed before now fails.

Verification:

  1. The new unit tests in generic-binder.test.ts and test_resolution.py, and the new check rule case, fail on main and pass with this change. The three operand cases already pass on main.
  2. web_core: 1659 unit tests and the conformance suite pass. python/a2ui_core: uv run pytest passes (2287 passed).
  3. Swift: swift test --filter BasicCatalogConformanceTests passes, including the four new cases. Dart was not run locally (no Dart SDK); its check reads valid == true, as above.
  4. ./scripts/fix_format.sh --check passes (Dart and Kotlin skipped locally; this change has no Dart or Kotlin 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.

scripts/e2e_test.sh runs the Flutter and Dart end-to-end tests with a Gemini API key; this change does not touch Dart or Flutter. No documentation change: the spec already says valid is a boolean.

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

@google-cla

google-cla Bot commented Nov 24, 2026

Copy link
Copy Markdown

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.

@oyobbeb
oyobbeb force-pushed the fix/check-non-boolean-valid branch from bc2f83f to fd8033c Compare November 24, 2026 07:52
@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 24, 2026

@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 validation logic to ensure that a check fails if its valid property is a non-boolean truthy value, aligning the Python and TypeScript implementations. It includes corresponding conformance and unit tests. The review feedback highlights an issue in the Python binder where the strict boolean check is only applied to dictionaries, leaving objects with a valid attribute vulnerable to Pydantic's type coercion. Moving this check outside the conditional block is recommended to ensure consistent enforcement.

@oyobbeb
oyobbeb force-pushed the fix/check-non-boolean-valid branch from fd8033c to 2b92df9 Compare November 24, 2026 08:27
@oyobbeb
oyobbeb marked this pull request as ready for review November 24, 2026 08:51
@Varun-S10 Varun-S10 self-assigned this Nov 24, 2026
@Varun-S10

Copy link
Copy Markdown
Collaborator

Hi @oyobbeb, 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 @pinieb, 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 24, 2026
@oyobbeb
oyobbeb force-pushed the fix/check-non-boolean-valid branch from 3678994 to 0bbbc5d Compare November 25, 2026 12:47
@pinieb

pinieb commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Hi @oyobbeb, 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 @pinieb, Could you please take a look?

This PR seems to be targeting TypeScript and Python, which I don't have great context on. @Varun-S10 could you help find a reviewer with more exposure to those parts of the monorepo? 😃

…ject#3175)

A check passed in TypeScript and Python when its condition resolved to
an object whose `valid` member is not a boolean, such as
`{"valid": "true"}`. TypeScript read it with `Boolean(rec.valid)`, and
Python's pydantic model read strings such as "yes" as True. Dart and
Swift fail these checks, and the spec says `valid` is a boolean.

Both now pass a check only when `valid` is `true`. Conformance cases pin
this for all four SDKs: a check rule in validation_result.yaml, and
and/or/not operands in functions.yaml, which a2ui-project#3850 already fixed but no
shared case covered.

The web_core and a2ui_core CHANGELOG entries mark this as a breaking
change.
…thon

The boolean check ran only for dict results, so an object with a
`valid` attribute such as "yes" still went through pydantic's lax
bool parsing. It now runs after the result is turned into a dict, for
every shape.
@oyobbeb
oyobbeb force-pushed the fix/check-non-boolean-valid branch from 0bbbc5d to 92ccd72 Compare December 1, 2026 04:01

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.

Cross-platform misalignment on v1.0 ValidationResult truthiness and non-boolean 'valid' fields

3 participants