Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

test(structured): pin the truthy non-array union shapes that were not iterable

Nandakishor696c3fded723
diff --git a/laya-java/fixtures/structured.json b/laya-java/fixtures/structured.json
index afc2a3b4..e546ee1b 100644
--- a/laya-java/fixtures/structured.json
+++ b/laya-java/fixtures/structured.json
@@ -3228,6 +3228,30 @@
},
"error": "properties.x: unsupported schema {'anyOf': {'a': 1}, 'oneOf': [{'type': 'boolean'}, {'type': 'null'}]}"
},
+ {
+ "case": "truthy-non-array-anyof-number",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "anyOf": 5
+ }
+ }
+ },
+ "error": "properties.x: unsupported schema {'anyOf': 5}"
+ },
+ {
+ "case": "truthy-non-array-oneof-boolean",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "oneOf": true
+ }
+ }
+ },
+ "error": "properties.x: unsupported schema {'oneOf': True}"
+ },
{
"case": "top-level-is-null",
"schema": null,
diff --git a/laya-java/scripts/gen_fixtures.py b/laya-java/scripts/gen_fixtures.py
index 1b69bd5e..1f47894c 100644
--- a/laya-java/scripts/gen_fixtures.py
+++ b/laya-java/scripts/gen_fixtures.py
@@ -4179,17 +4179,29 @@ STRUCTURED_REFUSALS = [
("recursive-ref",
{"type": "object", "properties": {"c": {"$ref": "#/$defs/Node"}},
"$defs": {"Node": {"$ref": "#/$defs/Node"}}}),
- # A TRUTHY non-array `anyOf` does NOT fall through to `oneOf`: it is iterated, yields no
- # mapping branch, and lands here. The other side of `falsy-anyof-falls-through-to-oneof`,
- # and the case a port testing "is it a list" gets wrong in the opposite direction -- it
- # falls through and, with nothing to fall through to, refuses with "unsupported schema"
- # instead of this.
+ # A non-array `anyOf`/`oneOf` is not a recognised optional wrapper, so it is left to the
+ # terminal "unsupported schema" rejection: the reference guards the unwrap with
+ # `isinstance(union, list)` (structured.py), which is what a port must test. Falsiness still
+ # decides the fall-through to `oneOf` first -- that is `falsy-anyof-falls-through-to-oneof`
+ # above -- and what survives it is only unwrapped when it is an array.
+ #
+ # The four shapes below are the whole surface, and each was a separate defect before #1364:
+ # a truthy string and a truthy object were ITERATED, yielding no mapping branch and reaching
+ # the `got 0` refusal, which blamed a union arity the request never had; a truthy number and
+ # a truthy boolean are not iterable at all and leaked `TypeError: 'int' object is not
+ # iterable` (`bool` subclasses `int`, so `true` leaked the same way). Keep all four pinned:
+ # they are the cases a port gets wrong in different directions, and only the first two would
+ # be caught by a fixture that stopped at strings and objects.
("truthy-non-array-anyof-is-not-a-fallthrough",
{"type": "object", "properties": {"x": {"anyOf": "abc"}}}),
("truthy-non-array-anyof-with-a-oneof-to-shadow",
{"type": "object", "properties": {"x": {"anyOf": {"a": 1},
"oneOf": [{"type": "boolean"},
{"type": "null"}]}}}),
+ ("truthy-non-array-anyof-number",
+ {"type": "object", "properties": {"x": {"anyOf": 5}}}),
+ ("truthy-non-array-oneof-boolean",
+ {"type": "object", "properties": {"x": {"oneOf": True}}}),
# The one case of the reference's top-level `isinstance(schema, dict)` check that is
# reachable on a side where the argument is typed: a list, a string or a number cannot be
# passed at all, and null can.