Skip to content

Commit

Permalink
Schema errors: HTTP status code must be between 400-599 (#197)
Browse files Browse the repository at this point in the history
If someone defined HTTP 200 for a schema error, the webrpc
clients wouldn't recognize it as an error. Instead, they'd
treat the response body as a regular response data object.
  • Loading branch information
VojtechVitek committed Mar 11, 2023
1 parent a6758ac commit e8a5e62
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions schema/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func (s *Error) Parse(schema *WebRPCSchema) error {
if s.Message == "" {
return fmt.Errorf("schema error: message cannot be empty")
}
if s.HTTPStatus < 100 || s.HTTPStatus >= 600 {
return fmt.Errorf("schema error: invalid HTTP status code '%v' for error type '%s' (must be number between 100-599)", s.HTTPStatus, s.Name)
if s.HTTPStatus < 400 || s.HTTPStatus > 599 {
return fmt.Errorf("schema error: invalid HTTP status code '%v' for error type '%s' (must be number between 400-599)", s.HTTPStatus, s.Name)
}

// check for duplicate codes or names
Expand Down

0 comments on commit e8a5e62

Please sign in to comment.