Skip to content

Object of type RequestError is not JSON serializable #698

@MetRonnie

Description

@MetRonnie

Description

(Tested on graphql-core v3 branch - #672)

A mutation error resulting in a RequestError does not get sent back to the GUI properly, instead it falls over at JSON serialization:

[E CylcUIServer] RequestError: Unknown argument "reloadGlobal" on field "reload" of type "Mutations".
    (Workflow is running in Cylc 8.4.3)
[E CylcHubApp tornado:420] Error: Object of type RequestError is not JSON serializable Traceback (most recent call last):
      File "~/cylc-uiserver/cylc/uiserver/graphql/tornado.py", line 163, in post
        await self.run("post")
      File "~/cylc-uiserver/cylc/uiserver/handlers.py", line 366, in run
        await TornadoGraphQLHandler.run(self, *args, **kwargs)
      File "~/cylc-uiserver/cylc/uiserver/graphql/tornado.py", line 185, in run
        result, status_code = await self.get_response(data)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "~/cylc-uiserver/cylc/uiserver/graphql/tornado.py", line 237, in get_response
        result = self.json_encode(response)
      File "~/cylc-uiserver/cylc/uiserver/graphql/tornado.py", line 248, in json_encode
        return json.dumps(d, separators=(",", ":"))
               ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "~/.conda/envs/gql-update/lib/python3.13/json/__init__.py", line 238, in dumps
        **kw).encode(obj)
              ~~~~~~^^^^^
      File "~/.conda/envs/gql-update/lib/python3.13/json/encoder.py", line 200, in encode
        chunks = self.iterencode(o, _one_shot=True)
      File "~/.conda/envs/gql-update/lib/python3.13/json/encoder.py", line 261, in iterencode
        return _iterencode(o, 0)
      File "~/.conda/envs/gql-update/lib/python3.13/json/encoder.py", line 180, in default
        raise TypeError(f'Object of type {o.__class__.__name__} '
                        f'is not JSON serializable')
    TypeError: Object of type RequestError is not JSON serializable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions