[Bug] Network errors are discarded.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with lib/graphql/client/http.rb around the Either-style return and lib/graphql/schema/loader.rb where load_schema consumes dump_schema. Trace the error path through load_schema and the other execute callers mentioned, including query(), then verify that HTTP or GraphQL errors remain available instead of becoming a KeyError.
Written by the indexing model from the issue text.
Description
If there's an HTTP error, calls to GraphQL::Client can return this:
KeyError: key not found: "data" (KeyError)
E.g., when I try the example in the readme to https://example.com/graphql, I expect some kind of network or HTTP error. Instead, I get the above KeyError.
I got this when making changes to my infrastructure. It made it very hard to debug problems.
I looked at load_schema, and found:
pry(main)> GraphQL::Client.load_schema(HTTP)
KeyError: key not found: "data" (KeyError)
from gems/3.4.0/gems/graphql-2.5.2/lib/graphql/schema/loader.rb:17:in 'Hash#fetch'
The load_schema call turns into load_schema(dump_schema(HTTP)). dump_schema seems to return full error info. So, between those two function calls, the information is lost:
[pry(main)> GraphQL::Client.dump_schema(HTTP)
=> {"errors" => [{"message" => "403 Forbidden"}]}
This happens other places that call execute, I believe, like .query().
In my opinion, the core problem is, the library uses fp-style Either error returns. However, Ruby doesn't have a way (like Rust or Haskell do) to enforce the handling of the error case. And so, it's possible to simply not handle them appropriately, like here.
Either-style API:
IMO, the fix is to use Ruby's Exception/Error facility so that library clients can meaningfully handle errors.
- Dominant language
- Ruby
- Stars
- 79
- Forks
- 227
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github-community-projects/graphql-client
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
github-community-projects/graphql-client#78 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
github-community-projects/graphql-client#77 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
github-community-projects/graphql-client#76 · 4 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
github-community-projects/graphql-client#75 · 1 comment · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
github-community-projects/graphql-client#65 · 1 comment ·
All issues in github-community-projects/graphql-client
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
OpenAPITools/openapi-generator#25768 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
olivierlacan/trebuche#8 ·
-
chore
Difficulty 1/5 Under an hour Newbie friendliness 84/100
AllYourBot/hostedgpt#929 ·
Maintainers usually reply within 1 day
-
Error toast on about page when domain blocks missingPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
sentry-rails: excluded_exceptions triggers a Rails deprecation warning for ActionController::InvalidAuthenticityTokenPossibly taken A pull request linked to this issue is open or already merged. OpenBug Ruby Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsentry/sentry-ruby#3228 · 1 comment ·
Maintainers usually reply within 1 day