这是indexloc提供的服务,不要输入任何密码
Skip to content

capture Postgres error code 22025 as HTTP 400 bad request #2486

@rakeshkky

Description

@rakeshkky

via maxpain (discord)

For request

{
  users(where: {
    nick_name: {
      _ilike: "maxpain\\"
    }
  }) {
    id
    nick_name
  }
}

Currently, the following error is thrown when an invalid pattern is given for _like operator. This should ideally be thrown as 400 Bad Request

{
  "errors": [
    {
      "extensions": {
        "internal": {
          "statement": "SELECT  coalesce(json_agg(\"root\" ), '[]' ) AS \"root\" FROM  (SELECT  row_to_json((SELECT  \"_1_e\"  FROM  (SELECT  \"_0_root.base\".\"id\" AS \"id\", \"_0_root.base\".\"nick_name\" AS \"nick_name\"       ) AS \"_1_e\"      ) ) AS \"root\" FROM  (SELECT  *  FROM \"public\".\"users\"  WHERE ((\"public\".\"users\".\"nick_name\") ILIKE ($2))     ) AS \"_0_root.base\"      ) AS \"_2_root\"      ",
          "prepared": true,
          "error": {
            "exec_status": "FatalError",
            "hint": null,
            "message": "LIKE pattern must not end with escape character",
            "status_code": "22025",
            "description": null
          },
          "arguments": [
            "(Oid 114,Just (\"{\\\"x-hasura-role\\\":\\\"admin\\\",\\\"x-hasura-user-id\\\":\\\"251586469\\\"}\",Binary))",
            "(Oid 25,Just (\"maxpain\\\\\",Binary))"
          ]
        },
        "path": "$",
        "code": "unexpected"
      },
      "message": "postgres query error"
    }
  ]
}

Metadata

Metadata

Assignees

Labels

c/serverRelated to servere/quickfixcan be wrapped up in few hoursp/urgentImmediate action required

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions