schema.errors callback not called when server returns 4xx status, intended?

1 Answer 83 Views
Data Source
Lynn
Top achievements
Rank 1
Iron
Lynn asked on 02 Aug 2021, 11:50 AM | edited on 02 Aug 2021, 11:50 AM

After trying to get my code to work for 2 hours now, I've found the source, which is explained exactly as SO question from years back: https://stackoverflow.com/questions/26723566/kendoui-datasource-schema-errors-not-firing-when-the-server-returns-400

Basically comes down to having a 4xx request (tried with 400 and 422), then the function inside errors won't be called and I can't properly propagate this to the error callback.

How should I approach this? It works fine on a 200 request, but that would be using the wrong http status code for the response.

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 05 Aug 2021, 10:34 AM

Hi Lynn,

The DataSource is looking for an error reported in the returned response to fire its error handler. That concerns server errors scenarios, when a response was returned from the endpoint. In the case of 4xx errors, there is no response returned from the server. As a consequence, the DataSource could not identify errors in that missing response.

Regards,
Veselin Tsvetanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Lynn
Top achievements
Rank 1
Iron
commented on 05 Aug 2021, 10:51 AM

In the case of 4xx errors, there is no response returned from the server. As a consequence, the DataSource could not identify errors in that missing response.
There most certainly is a response, and this is allowed by the specifications of 4xx error codes, the data source should handle this accordingly.
Veselin Tsvetanov
Telerik team
commented on 06 Aug 2021, 07:05 AM

I beg your pardon for the incorrect statement in my previous reply. As you have correctly noted, the response is present and that is a 4XX response. What is not present in the response is a response body. The DataSource checks if that body contains an errors field (or specified otherwise in the DataSource.schema.errors) and if yes, it triggers the error event.
Lynn
Top achievements
Rank 1
Iron
commented on 06 Aug 2021, 10:10 AM

Again, 4xx may contain response bodies, and my request also contained a response body. I have tested this with the exact same response body between 2 different requests where only the status code was different.

Currently 4xx errors do not read the response body even when present, and they may be present according to the RFC for at least 422, but works for every 4xx.

Veselin Tsvetanov
Telerik team
commented on 10 Aug 2021, 01:17 PM

Hi Lynn,

Attached you will find a simple .Net Core app implementing the scenario in question. You will notice that the error event is raised for the 404 response that is returned from the server. The response body is also available in the e.xhr.responseJSON event argument.

May I ask you to modify the above, so that it reproduces the issue observed at your end and send it back to me? This way I will be able to troubleshoot the problem locally and to provide you with the most appropriate assistance on the above.

Looking forward to hearing from you.

Tags
Data Source
Asked by
Lynn
Top achievements
Rank 1
Iron
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or