Repository navigation
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. |
bc2f83f to
fd8033c
Compare
There was a problem hiding this comment.
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.
fd8033c to
2b92df9
Compare
3678994 to
0bbbc5d
Compare
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.
0bbbc5d to
92ccd72
Compare
Problem
A check rule passes in TypeScript and Python when its condition resolves to an object whose
validmember is not a boolean, while Dart and Swift fail it. The spec says a check condition evaluates to a boolean or aValidationResult, whosevalidis a boolean.Boolean(rec.valid)inextractValidationResult, so{"valid": "true"}passes, and so does{"valid": "false"}._process_rule_val, which reads strings such as"true"and"yes"asTrue.map['valid'] == trueinvalidityOf, and Swift reads only a booleanvalidinmakePathBoundCheck, so both fail these checks.#3850 fixed the
and,orandnotpart of #3175 and its docs part, but no shared conformance case pins theand,orandnotbehavior. The check rule part is still open. The issue says TypeScript already fails these checks, but at the time it also usedBoolean(rec.valid).Fixes #3175
Changes
validistrue.validthat is notTrueis read asFalsebefore pydantic validates the result.test_validation_result_non_boolean_valid_failsinconformance/core/validation_result.yamlpins the check rule behavior for all four SDKs. Three cases inconformance/core/functions.yaml(test_evaluate_function_and_non_boolean_valid_operandand itsorandnotsiblings) pin theand,orandnotbehavior 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).web_coreanda2ui_core, marked as breaking because a check that passed before now fails.Verification:
generic-binder.test.tsandtest_resolution.py, and the new check rule case, fail onmainand pass with this change. The three operand cases already pass onmain.web_core: 1659 unit tests and the conformance suite pass.python/a2ui_core:uv run pytestpasses (2287 passed).swift test --filter BasicCatalogConformanceTestspasses, including the four new cases. Dart was not run locally (no Dart SDK); its check readsvalid == true, as above../scripts/fix_format.sh --checkpasses (Dart and Kotlin skipped locally; this change has no Dart or Kotlin files).Pre-launch Checklist
One time:
For this PR:
scripts/e2e_test.shruns 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 saysvalidis a boolean.If you need help, consider asking for advice on the discussion board.