hasura / hasura/graphql-engine
Inconsistent error reporting in Hasura API
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
I'm using hasura/graphql-engine:v1.1.0 and I try to send some Hasura API JSON-s to configure Hasura.
I have two remote schemas I try to add to hasura via environment variables (REMOTE_SCHEMA_JAVA_BACKEND, REMOTE_SCHEMA_UCPPS_CONNECTOR). I practically send the same JSON for the two remote schemas, however I receive different error objects back if these schemas have already been set.
This is the first JSON
```json
{
"type": "add_remote_schema",
"args": {
"name": "REMOTE_SCHEMA_JAVA_BACKEND",
"definition": {
"url_from_env": "REMOTE_SCHEMA_JAVA_BACKEND",
"headers": [
],
"timeout_seconds": 60,
"forward_client_headers": true
}
}
}
```
And this is the error I get:
```json
{
"path": "$.args",
"internal": {
"prepared": true,
"statement": "\n INSERT into hdb_catalog.remote_schemas\n (name, definition, comment)\n VALUES ($1, $2, $3)\n ",
"arguments": [
"(Oid 25,Just (\"REMOTE_SCHEMA_JAVA_BACKEND\",Binary))",
"(Oid 114,Just (\"{\\\"timeout_seconds\\\":60,\\\"headers\\\":[],\\\"url_from_env\\\":\\\"REMOTE_SCHEMA_JAVA_BACKEND\\\",\\\"forward_client_headers\\\":true}\",Binary))",
"(Oid 0,Nothing)"
],
"error": {
"status_code": "23505",
"hint": null,
"exec_status": "FatalError",
"description": "Key (name)=(REMOTE_SCHEMA_JAVA_BACKEND) already exists.",
"message": "duplicate key value violates unique constraint \"remote_schemas_name_key\""
}
},
"code": "unexpected",
"error": "postgres query error"
}
```
For the other schema I send pretty much the same JSON:
```json
{
"type": "add_remote_schema",
"args": {
"name": "REMOTE_SCHEMA_UCPPS_CONNECTOR",
"definition": {
"url_from_env": "REMOTE_SCHEMA_UCPPS_CONNECTOR",
"headers": [
],
"timeout_seconds": 60,
"forward_client_headers": true
}
}
}
```
And I get the error in this format:
```json
{
"path": "$.args",
"code": "already-exists",
"error": "remote schema with name \"REMOTE_SCHEMA_UCPPS_CONNECTOR\" already exists"
}
```
Which one is the expected format of errors? I myself would prefer the first one with the internal details.
Contributor guide
Assessment
This issue has not been assessed yet.