Skip to content

Actions: status code expected to be string in error responses from handler #5033

Open
@dminkovsky

Description

@dminkovsky

When my handler returns an error to Hasura like:

{
    "code": 400,
    "message": "\"password\" length must be at least 8 characters long"
}

I get this GraphQL response from Hasura:

{
  "errors": [
    {
      "extensions": {
        "internal": {
          "error": "unexpected response",
          "response": {
            "status": 400,
            "body": {
              "code": 400,
              "message": "\"password\" length must be at least 8 characters long"
            },
            "headers": [
              {
                "value": "Origin",
                "name": "Vary"
              },
              {
                "value": "true",
                "name": "Access-Control-Allow-Credentials"
              },
              {
                "value": "application/json; charset=utf-8",
                "name": "Content-Type"
              },
              {
                "value": "79",
                "name": "Content-Length"
              },
              {
                "value": "W/\"4f-drjEwWPRkWE+5vLBcl+Dmp174R0\"",
                "name": "ETag"
              },
              {
                "value": "Tue, 09 Jun 2020 20:48:28 GMT",
                "name": "Date"
              },
              {
                "value": "keep-alive",
                "name": "Connection"
              }
            ]
          },
          "request": {
            "body": {
              "session_variables": {
                "x-hasura-role": "admin"
              },
              "input": {
                "username": "bill",
                "password": "orr"
              },
              "action": {
                "name": "createAccount"
              }
            },
            "url": "http://host.docker.internal:3010/auth/register",
            "headers": []
          }
        },
        "path": "$.code",
        "code": "parse-failed"
      },
      "message": "parsing Text failed, expected String, but encountered Number"
    }
  ]
}

Looks like Hasura is expecting $.code to be to be a String, which complicates my code and seems wrong? Wouldn't it be better if it it could handle a Number?

Metadata

Metadata

Assignees

Labels

a/apic/actionsRelated to actionsc/serverRelated to serverk/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions