Skip to content

Handle 404 more gracefully / explicitly #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mausch opened this issue May 11, 2023 · 1 comment
Closed

Handle 404 more gracefully / explicitly #415

mausch opened this issue May 11, 2023 · 1 comment
Labels
type: question or discussion Issue discussing or asking a question about gql

Comments

@mausch
Copy link

mausch commented May 11, 2023

Hi and thanks for this project!

Describe the bug
When getting a 404 I get an unrelated stack trace as the code doesn't seem to handle the response status:

Traceback (most recent call last):
  File "/home/mauricio/prg/elevate/elevate-chatbot/.mamba/envs/chatbot/lib/python3.10/site-packages/gql/client.py", line 285, in execute_async
    return await session.execute(
  File "/home/mauricio/prg/elevate/elevate-chatbot/.mamba/envs/chatbot/lib/python3.10/site-packages/gql/client.py", line 1220, in execute
    result = await self._execute(
  File "/home/mauricio/prg/elevate/elevate-chatbot/.mamba/envs/chatbot/lib/python3.10/site-packages/gql/client.py", line 1126, in _execute
    result = await asyncio.wait_for(
  File "/home/mauricio/prg/elevate/elevate-chatbot/.mamba/envs/chatbot/lib/python3.10/asyncio/tasks.py", line 447, in wait_for
    return fut.result()
  File "/home/mauricio/prg/elevate/elevate-chatbot/.mamba/envs/chatbot/lib/python3.10/site-packages/gql/transport/aiohttp.py", line 325, in execute
    if "errors" not in result and "data" not in result:
TypeError: argument of type 'NoneType' is not iterable

To Reproduce
Steps to reproduce the behavior:
Point any gql query to a server that responds with 404.

Expected behavior
An explicit exception mentioning that the status was 404.

System info (please complete the following information):

  • OS: Linux
  • Python version: 3.10
  • gql version: 3.4.1
  • graphql-core version: 3.2.3
@leszekhanusz leszekhanusz added the type: question or discussion Issue discussing or asking a question about gql label May 11, 2023
@leszekhanusz
Copy link
Collaborator

404 errors should raise a TransportServerError.

Your problem seems that the 404 answer received from the backend is empty and it is causing a bug which has already been fixed in version v3.5.0a0

Upgrading to the latest pre-release version v3.5.0b4 should fix your problem.

You should also consider adding an html answer in your backend for your 404 response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about gql
Projects
None yet
Development

No branches or pull requests

2 participants