Hi,
I’ve been using your GraphQL API extensively for a while now and I think it is about time to write you a few sentences about error handling that I think you could improve.
Overall I think your API is working great but when we come to error handling it is very bad (if you ask me).
Usually when using REST API the HTTP status code 200 always means that the request went OK. But this isn’t the case with Monday.com GraphQL API. In almost all cases I am getting HTTP status code 200 but the response then doesn’t contain the expected response. Instead it contains the error message. See the example below:
{"error_message":"This column ID doesn't exist for the board","error_code":"InvalidColumnIdException","error_data":{"column_id":"text2","board_id":null,"error_reason":"store.monday.automation.error.missing_column"},"status_code":200,"account_id":22225094}
If necessary I can copy-paste the request body but for sake of ease I will omit it for now.
The HTTP request has HTTP status code 200 but the response is an error. Why don’t you use HTTP error code 4xx for this use-case? There are plenty of 4xx error codes you can use for this purpose.
In order to handle this kind of error I have to check each and every response like following (Swift code):
if lowercasedDataString.contains("\"error_code\":\"ComplexityException\"".lowercased()) ||
lowercasedDataString.contains("\"error_code\":\"complexityBudgetExhausted\"".lowercased()) ||
lowercasedDataString.contains("\"error_code\":\"ColumnValueException\"".lowercased()) ||
lowercasedDataString.contains("\"status_code\":429".lowercased()) {
... error 1
} else if dataString.contains("\"error_code\":\"ResourceNotFoundException\"") &&
dataString.contains("\"status_code\":404") {
... errror 2
}
...etc.
The example above is just a small code snippet of how my error handling looks like.
And I have to do this for each HTTP request because every request returns with HTTP status code 200. Definitely not the most performant code we can get.
Secondly, I have to rely on searching for error messages that can change at any moment. I.e. if some developer makes a typo then my error checking code won’t work properly anymore.
On the other hand, if you would return this as HTTP status code 4xx then I would do this check only in case of HTTP status code 4xx. Or even better, if you would enumerate each and every error by HTTP status code then I could simply compare them by the code number.
The other part of the problem is the fact that I can’t find the list of all possible errors that your system can throw. This means I simply have to force a lot of different scenarios that would simulate problems and collect all possible errors.
In the end this leads me in the situation where my users end up having errors that I forgot to create. Again, definitely not the best UX you can offer to the users.
Please don’t get me wrong, I appreciate the work you have done with your API and the constant improvements you deliver to us by regular API updates! I would be really happy if you can also make some improvements with error handling
Thanks,
Josip