service: FieldErrors rendered as "Internal Server Error"

FieldErrors results in 500 status code being rendered for two reasons:

  1. Errors middleware explicitly looks for errs.Error type and if not found, returns 500 status code,
  2. httpStatus interface is not yet implemented for FieldErrors, therefore case error: switch case inside web.Response wins and results in Internal Server Error.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

We agree the parseFilter function must return an error. We can’t walk away from this idiom.

We want a FieldsError with multiple reported problems when calling parseFilter

We need an *errs.Error because that is what implements the encoder interface.

I think this commit provides the solution.

https://github.com/ardanlabs/service/commit/d818ca8ca52e0237701b0b5b57fa0938a15f48ab

I really would like to have just the 1 error type that implements the encoder interface. This better controls what can flow through the system as it related to errors.

Nice catch.

I think the change needs to be for that NewFieldsError to return an errs.Error with the field error wrapped. To fix the other to type assert to errs.Error

let me look at this today.