graphql-python / graphql-python/graphene

Depth limit validator key error if fragment undefined

Aperta
#1,538 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
🐛 bug
Lingua principale
Python
Stelle
8.2k
Fork
818
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

**Current behaviour:**
When using the `depth_limit_validator` ([docs](https://docs.graphene-python.org/en/latest/execution/queryvalidation/#usage)), an invalid query can lead to a `KeyError` being thrown (from [here](https://github.com/graphql-python/graphene/blob/master/graphene/validation/depth_limit.py#L148)), which usually results in the API returning a 500 server error.

To reproduce:
- Add the `depth_limit_validator` to the `validation_rules` in your `GraphQLView`.
- Execute a query with an undefined fragment, i.e. something like:
```
query {
validQuery {
validField
...undefinedFragment
}
}
```

**Expected behaviour:**
A standard validation error response, like:
```
{
"errors": [
{
"message": "Unknown fragment 'undefinedFragment'.",
"locations": [
{
"line": x,
"column": y
}
]
}
]
}
```

Since this is something that's caught by the standard validators, `depth_limit_validator` should probably just skip such errors. Or, do whatever the other validators do when they hit an "unrelated" error.

**Environment:**
- Version: 3.3
- Platform: n/a

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Esamina graphene/validation/depth_limit.py intorno alla riga 148, quindi riproduci la query con un frammento non definito, con depth_limit_validator configurato su GraphQLView. Assicurati che questo caso produca la risposta di validazione standard per un frammento sconosciuto invece di un KeyError o di un errore 500.

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

Valutazione

Stack tecnologico
graphql, python
Ambito
api, backend-api-design
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.