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

TypeError in `normalize_error_paths` with federated routers

Aperta
#78 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Inizia in graphql/client/errors.rb, in Errors.normalize_error_paths, ed esegui la riproduzione fornita con il percorso federato "@". Confrontala con l'esempio con indice intero; il lavoro è completato quando il caso "@" restituisce il normalizedPath previsto senza sollevare TypeError, mentre il caso intero continua a funzionare.

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

Descrizione

We are using WunderGraph's Cosmo Router for GraphQL federation. When the resolver fails to bulk load data in an array context from a federated subgraph, the router will include an @ in the error paths for those errors, instead of an array index integer. From my research, this is semi-standard with federated routers like Cosmo and Apollo Router. When processing the response in these cases, the graphql client will fail with the following error:

TypeError: no implicit conversion of String into Integer
--
0: ruby/3.2.5/lib/ruby/gems/3.2.0/gems/graphql-client-0.26.0/lib/graphql/client/errors.rb:27:in `block (2 levels) in normalize_error_paths'
1: ruby/3.2.5/lib/ruby/gems/3.2.0/gems/graphql-client-0.26.0/lib/graphql/client/errors.rb:24:in `each'
2: ruby/3.2.5/lib/ruby/gems/3.2.0/gems/graphql-client-0.26.0/lib/graphql/client/errors.rb:24:in `block in normalize_error_paths'
3: ruby/3.2.5/lib/ruby/gems/3.2.0/gems/graphql-client-0.26.0/lib/graphql/client/errors.rb:21:in `each'
4: ruby/3.2.5/lib/ruby/gems/3.2.0/gems/graphql-client-0.26.0/lib/graphql/client/errors.rb:21:in `normalize_error_paths'
...

it's happening on this line in Errors.normalize_error_paths while validating the paths exist in the data:

current = current[key]

in this context, current is an array, but key is "@", which is causing a type error.

Reproducing the error:

errs_with_at = [{"message"=>"boom", "locations"=>[{"line"=>1, "column"=>113}], "path"=>["records", "@", "item"]}]
GraphQL::Client::Errors.normalize_error_paths({"records"=>[{"item"=>nil}]}, errs_with_at)
Expected result:
[{"message"=>"boom", "locations"=>[{"line"=>1, "column"=>113}], "path"=>["records", "@", "item"], "normalizedPath"=>["data", "records", "@", "item"]}]
Actual result
TypeError: no implicit conversion of String into Integer
from /Users/tlubitz/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/graphql-client-0.26.0/lib/graphql/client/errors.rb:27:in `block (2 levels) in normalize_error_paths'

By contrast, the same invocation works if you replace "@" with e.g. 0:

errs = [{"message"=>"boom", "locations"=>[{"line"=>1, "column"=>113}], "path"=>["records", 0, "item"], "normalizedPath"=>["data", "records", 0, "item"]}]
GraphQL::Client::Errors.normalize_error_paths({"records"=>[{"item"=>nil}]}, errs)

 [{"message"=>"boom", "locations"=>[{"line"=>1, "column"=>113}], "path"=>["records", 0, "item"], "normalizedPath"=>["data", "records", 0, "item"]}]
Lingua principale
Ruby
Stelle
78
Fork
228
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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 github-community-projects/graphql-client

Tutte le issue di github-community-projects/graphql-client

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.