Draft 2019-09 unevaluatedItems crashes when items is a boolean schema
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
The report identifies jsonschema/_legacy_keywords.py and the find_evaluated_item_indexes_by_schema helper; start by reading that helper alongside the items_draft6_draft7_draft201909 dispatch. Reproduce with the supplied schema and check the regression cases described for boolean items, combinators, and $ref. Done means boolean schemas no longer crash and the reported validation behavior is covered by passing tests.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Draft201909Validator raises TypeError: object of type 'bool' has no len() when a boolean items schema is combined with unevaluatedItems, even when the instance is an empty array.
Reproduced with released jsonschema 4.26.0 on CPython 3.14.4 and with current main at c497561ea0a95f5aac09cd63d15eb1420eb7bbec.
from jsonschema import Draft201909Validator
schema = {"items": True, "unevaluatedItems": False}
Draft201909Validator.check_schema(schema) # succeeds
print(list(Draft201909Validator(schema).iter_errors([1, 2])))
Expected: [], because items: true evaluates every item successfully.
Actual:
File "jsonschema/_legacy_keywords.py", in find_evaluated_item_indexes_by_schema
evaluated_indexes += list(range(len(schema["items"])))
TypeError: object of type 'bool' has no len()
The same crash occurs with items: false. An empty array should be valid in that case; a nonempty array should produce ordinary validation errors. Replacing the boolean items schema with an object schema avoids the crash.
Draft 2019-09 §9.3.1.1 permits a single schema or an array of schemas for items. Boolean schemas are valid single schemas. §9.3.1.3 describes how unevaluatedItems consumes the resulting annotations.
The evaluated-item helper recognizes an object as a single schema, but treats any other value as an array and calls len() on it. A local fix changes that condition to not validator.is_type(schema["items"], "array"), matching the dispatch already used by items_draft6_draft7_draft201909.
The local patch includes regressions for both booleans, nonempty-array rejection with items: false, allOf/anyOf/oneOf, and $ref. Before the fix, the four new test methods produced 12 TypeErrors. After the fix, the full 8,533-test discovery run exited successfully; the 29-test Draft 2019-09 validator class, lint, formatting, and typing checks also pass. An independent automated reviewer ran the 8,016-test official JSON Schema suite successfully (232 skipped).
I searched open and closed issues and PRs for unevaluatedItems, boolean items, and this exception. #867 concerns a boolean instance and a different exception; I did not find a report of this boolean-schema case.
The repository currently restricts PR creation to collaborators, so no PR has been opened. The tested patch is retained locally pending maintainer direction.
AI disclosure: this report, reproduction, local fix, and regression tests were prepared using OpenAI Codex, with independent review by a separate native GPT-6 Sol agent. This is automated work and still needs maintainer review.
- Lenguaje dominante
- Python
- Estrellas
- 5k
- Forks
- 700
- Merge medio
- 2 d 1 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python-jsonschema/jsonschema
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
python-jsonschema/jsonschema#1588 · 2 comentarios ·
-
Iterator error contexts lose parent links and absolute pathsQuizá libre de nuevo @DawnofGenX la tomó hace 13 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
python-jsonschema/jsonschema#1584 · 3 comentarios ·
-
regex format checker crashes with RecursionError on deeply nested patternsPosiblemente ocupada @DawnofGenX la tomó hace 13 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
python-jsonschema/jsonschema#1538 · 1 comentario ·
-
is_duration raises an uncaught decimal.Overflow on a duration with a large exponentQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoNeeds Test Upstream
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
python-jsonschema/jsonschema#1511 · 1 comentario ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 20/100
python-jsonschema/jsonschema#1589 ·
Todos los issues de python-jsonschema/jsonschema
Issues similares
-
documentation good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
drevendev/HungryCrab#273 ·
Los mantenedores suelen responder en 1 día
-
good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
drevendev/BeautifulRepo#19 ·
Los mantenedores suelen responder en 2 días
-
Moonshot: Kimi K3 always sends `reasoning_effort="max"`, though the API now accepts `low` and `high`Abiertoaccepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
UKGovernmentBEIS/inspect_ai#5939 ·
Los mantenedores suelen responder en 1 día
-
bug linux
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Fill paper for Screen2WordsAbiertoarea:data data-quality
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
reacher-z/Awesome-CUA#1468 ·
Los mantenedores suelen responder en 1 día