Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Mutating validators are difficult to debug

Aperta
#1,338 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

  • #1339 di @stephenfin — chiusa senza merge

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Esamina nova/api/validation/validators.py intorno alla riga 182 e il percorso di validazione di oneOf. Riproduci la mutazione con un validatore che elimina le chiavi, quindi usa i test per verificare che i controlli successivi dei sotto-schemi ricevano l’istanza originale; l’issue non specifica quale delle mitigazioni proposte dovrebbe essere accettata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Dialects v2

I saw strange issues while adding schemas to a project I was working on. Despite knowing I was passing a valid instance in, I was getting errors like {} is not valid under any of the given schemas. I eventually traced this down to one of the in-tree validators (here, fwiw), which has the unfortunate side-effect of mutating the input instance. When the schema is using oneOf, the check against the first sub-schema ended up deleting all keys from the instance, causing the checks against subsequent sub-schemas to fail.

This is 100% not an issue with jsonschema but it is something I think it might be able to help mitigate. I could see us either (a) always doing a deepcopy of the instance before passing it to the validator, or (b) doing a deepcopy and comparing against instance after the call, with an exception raised if they're not identical. There might also be other approaches possible. In any case, I'm happy to help resolve this, assuming we agree it's a thing we'd like to address.

Lingua principale
Python
Stelle
5k
Fork
694
Merge medio
1g 20h
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-jsonschema/jsonschema

Tutte le issue di python-jsonschema/jsonschema

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.