pwm-project / pwm

pwm
Other
912 stars 250 forks source link

REST Health service error #634

Open maniac777 opened 2 years ago

maniac777 commented 2 years ago

Describe the bug In current version of application GIT main and in previous release health reset service is not responding.

To Reproduce Steps to reproduce the behavior:

  1. Enable public health service.
  2. Try to call it with following headers:
    
    GET /pwm/public/rest/health HTTP/1.1
    User-Agent: check_http/v2.1.1 (monitoring-plugins 2.1.1)
    Connection: close
    Host: __DOMAIN__
    Accept: */*

HTTP/1.1 200 Date: Tue, 21 Dec 2021 08:07:02 GMT Server: PWM Vary: Accept-Encoding Content-Language: en X-PWM-Noise: NrYK7GhqY6mqmG4prVj X-Content-Type-Options: nosniff X-XSS-Protection: 1 X-PWM-Instance: 37F1484C92C74383 X-Frame-Options: DENY X-PWM-Amb: j00s j0ur d4ddy Cache-Control: no-cache, no-store, must-revalidate, proxy-revalidate Content-Type: application/json;charset=UTF-8 Content-Length: 74 X-Robots-Tag: noindex, noarchive, nosnippet Connection: close CONTENT {"error":true,"errorCode":7000,"errorMessage":"Error_RestInvocationError"}



**Expected behavior**
I expect to receive json object with health status as in previous releases.
maniac777 commented 2 years ago

I've debugged out a problem a bit with colegue. He found out that in server/src/main/java/password/pwm/ws/server/rest/RestHealthServer.java there are two methods:

1. @RestMethodHandler( method = HttpMethod.GET, produces = HttpContentType.plain ) private RestResultBean doPwmHealthPlainGet( final RestRequest restRequest ) 2. @RestMethodHandler( method = HttpMethod.GET, consumes = HttpContentType.json, produces = HttpContentType.json ) private RestResultBean doPwmHealthJsonGet( final RestRequest restRequest )

This was a hint. In first method any error is catched. So this was a hint that i did not hit the first method. Setting request header "Content-Type: text/plain" clould be enaugh to make it working.

I believe that this should be fixed to give some more helpfull error message, documented or fixed in the way that content-type is not required in GET request.

msoltyspl commented 1 year ago

For the record, this is still an issue in version 2.0.4 (forcing content-type to application/json with e.g. curl's -H workarounds the issue as well)