"Error Codes" fields are not returned by GraphQL query

Hi all,
do you know if this article about Error Codes is up to date?

As far as I can see I don’t receive any error_code, status_code, error_message or error_data fields, but a simple errors array containing a message field.

For example, triggering an error on purpose by calling a non-existing xxx field, I get the following errors array:

Array
(
  [0] => stdClass Object
  (
    [message] => Field 'xxx' doesn't exist on type 'Query'
    [locations] => Array
    (
      [0] => stdClass Object
      (
        [line] => 1
        [column] => 129
      )
    )
    [fields] => Array
    (
      [0] => query
      [1] => xxx
    )
  )
)

Do you know how to get the fields mentioned in the article?
Thanks.

@dipro @VladMonday Any feedback? Thanks.

Hello @rob!

Which query did you use to get that message you showed there?

What I have realized is that, even though monday.com does send these error_code , status_code , error_message or error_data fields, they are not catchable making them essentially useless.
If you open your console and check the network tab, you might see these error fields.
I thought it was only on my end but since @rob is also reporting the issue, it seems that it might be a general problem

1 Like

Just a simple

{
  me {
    id
    xxx
  }
}

Or any other queries containing an error.

I couldn’t even get the errors above by triggering the error on purpose using the API Playground.

Also triggering another error, like the complexity exhausted, with a query like this:

{
  boards {
    items {
      id
      subitems {
        id
      }
    }
  }
}

I get the following response:

{
  "errors": [
    {
      "message": "Query has complexity of 25275260, which exceeds max complexity of 5000000"
    }
  ],
  "account_id": 123
}

So I don’t get the ComplexityException as written in the article at Error codes.

Any feedback from monday devs?

Any update on this @Matias.Monday ?

Hello again @rob!

We will take a look into the documentation and change what needs to be changed.

Thank you for the feedback!

Cheers,
Matias

1 Like

In addition, I’ve noticed that if you try to change a column value using an invalid item ID or board ID

mutation {
  change_simple_column_value(item_id: 123, board_id: 456, column_id: "date4", value: "") {
    id
  }
}

You get a

{
  "error_message": "Internal server error",
  "status_code": 500
}

While if you use an invalid column ID

mutation {
  change_simple_column_value(item_id: 3184567637, board_id: 3184567625, column_id: "xxx", value: "") {
    id
  }
}

You get the expected error

{
  "error_code": "InvalidColumnIdException",
  "status_code": 200,
  "error_message": "invalid column id xxx, please check our API documentation for the correct data structure for this column. https://api.developer.monday.com/docs/change-column-values",
  "error_data": {
    "column_id": {
      "column_value": "",
      "column_id": "xxx"
    },
    "error_reason": "store.monday.automation.error.missing_column"
  }
}

Please fix it.

@Matias.Monday

I’d also add that the “error_code” “error_message”, “error_data” objects are non-standard for GraphQL errors.

GraphQL standard is a “data” object with data and “errors” object with error data. “errors” objects have the following shape:

{
    "errors": [{
        "message": "string",
        "extensions":{ "key1":"string", "key2":"string"}
    }]
}

The Apollo Client (GraphQL) can be configured to throw an exception on on the payload having an errors object. This way Apollo Client (or Apollo Link) will handle a 200 with an errors object as an exception.

However Apollo does not look for the non-standard “error_codes” field in the response as that is not part of the GraphQL spec. You’re then required check your response object for “error_code” and/or lack of a “data” object and throw an exception yourself.

The “errors” object should be used for any errors related to an actual operation - such as column_id not existing on a board, item_id missing, etc.

Apollo Client error handling unfortunately the server-side SDK does not use Apollo Client (though Apollo Link work with some setup, rather than the SDK).

I would highly encourage the monday.com team to move all API errors that are caught (invalid column id xxx) as part of the “errors” object. However, i acknowledge the difficulty of this, especially if client side (web ui) code does not have exception handling for these errors in place.

2 Likes

Hello y’all!

Thank you for the feedback and suggestions.

I will share all of this with the team :slightly_smiling_face:

Cheers,
Matias

Hi @Matias.Monday, is any update available on this issue?

A reliable method for parsing and handling errors is an important requirement for any production application. The docs remain incorrect, and the error codes defined there are not returned. Thanks.

1 Like

Hello there,

I do not have an update yet from our R&D team about this.

I will speak with them again and send again the feedback about the documentation so we can take a look into it.

Cheers,
Matias