stack icon indicating copy to clipboard operation
stack copied to clipboard

Bug: Internal Server Error Instead of Proper Error When Nested CRUD Handler Throws Error

Open kfahad5607 opened this issue 1 year ago • 1 comments

Description:

When a CRUD handler A is called inside another CRUD handler B, known errors thrown from A are not properly propagated.

Reproduction:

Trying to change the selected team with a non-existent team ID via Update Current User API.

Error Example

The correct error was thrown but not propagated correctly.

APIs with this issue:

  1. Get Current User
  2. Delete Current User
  3. Update Current User

Probable Solution:

Add expected errors in allowedErrorTypes while calling CRUD handlers.

Solution Example

Now, allowed errors should propagate properly.

Propagated Error Example

Now we get an appropriate error instead of an internal server error.

Correct Error Example

Additional Notes:

I would love to work on this issue. Please assign it to me if possible.

kfahad5607 avatar Aug 10 '24 16:08 kfahad5607

@fomalhautb Can I directly add StatusError into allowedErrorTypes instead of adding individual errors? If we add StatusError then we do not need to worry about updating the allowedErrorTypes every time we change/add a error raised inside nested CRUD handlers. Because all known errors are StatusError anyway.

kfahad5607 avatar Aug 11 '24 07:08 kfahad5607