rexyai / RestRserve

R web API framework for building high-performance microservices and app backends
https://restrserve.org
275 stars 32 forks source link

[BUG] The HTTPError$unprocessable_entity() has an invalid error code. #141

Closed junghwan-yun closed 4 years ago

junghwan-yun commented 4 years ago

Describe the bug

The http error code for "unprocessable entity" is 422, but it is incorrectly entered as 417.

RestRserve/R/HTTPError.R line 234 - 235

#' @description
#' Generates corresponding http error.
#' @param ... Additional named arguments which will be passed to `Response$new()`.
#' @return [Response] object.
unprocessable_entity = function(...) {
      private$prepare_response(417L, ...)
},

Expected behavior

Please adjust the error code to 422.

#' @description
#' Generates corresponding http error.
#' @param ... Additional named arguments which will be passed to `Response$new()`.
#' @return [Response] object.
unprocessable_entity = function(...) {
      private$prepare_response(422L, ...)
},

Environment information

R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8    
 [5] LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C             
 [9] LC_ADDRESS=C           LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] paws.machine.learning_0.1.7 paws_0.1.7                  magick_2.3                 
 [4] parsedate_1.2.0             aws.s3_0.3.21               jsonlite_1.6               
 [7] forcats_0.4.0               stringr_1.4.0               dplyr_0.8.0.1              
[10] purrr_0.3.3                 readr_1.3.1                 tidyr_0.8.3                
[13] tibble_2.1.1                ggplot2_3.1.1               tidyverse_1.2.1            
[16] RestRserve_0.2.2  
artemklevtsov commented 4 years ago

Thank you for the report. Confirmed: https://developer.mozilla.org/ru/docs/Web/HTTP/Status/422

artemklevtsov commented 4 years ago

Feel free to send PR in the same cases.

dselivanov commented 4 years ago

@junghwan-yun thanks for good report! fixed in dev branch now. Ticket will be closed automatically after dev will merged to the master.