Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Customize error messages (e.g. for translations)

Abierto
#971 8 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python
Área
backend

Línea de trabajo

Comienza con la documentación de ValidationError y el manejo de additionalProperties en jsonschema/_validators.py, incluido su uso de _utils.find_additional_properties. Revisa el issue relacionado #564 y el contexto de error existente para determinar el alcance de un mecanismo de mensajes configurable. El resultado debe ser un diseño revisado con una forma clara de admitir mensajes traducidos y específicos para cada error sin duplicar la lógica del validador.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Enhancement Error Reporting

Hi,
I would need to translate the error messages and it happens to be more complicated than I expected (or than it could be, I believe).
I started using information on ValidationErrors to define custom messages, but all relevant information for the message is not always readily available. Found this related issue #564 but with not much follow-up so I thought I could ask again.

For instance, for an "additionalProperties" keyword, looking at the code shows that there is some logic that needs to be reimplemented to make message translations (using internal _utils.find_additional_properties to find the offending properties, two different messages depending on whether properties or patternProperties is used etc.).

In addition to the overhead this introduces, I am afraid that it may drift out of sync with the logic in this package in case of improvements, bug fixes, or new draft support etc. or that internal functions may change without backward compatibility.

I am wondering if it would be possible to not hard-code messages, but use templates instead (e.g. Jinja2), that have access to error-specific contextual data (e.g. offending properties for "additionalProperties" errors), and that could be changed for a translation without touching at the logic. This is for instance the approach taken by xeipuuv/gojsonschema.

I think it would be worth a try, and I would be willing to contribute on this with a little help, if you think it is a good idea.

Lenguaje dominante
Python
Estrellas
5k
Forks
694
Merge medio
1 d 20 h
PR fusionados (30 d)
6

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python-jsonschema/jsonschema

Todos los issues de python-jsonschema/jsonschema

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.