spring-cloud-config icon indicating copy to clipboard operation
spring-cloud-config copied to clipboard

UnknownContentTypeException when client authentication to server fails

Open eduanb opened this issue 4 years ago • 2 comments

When the server has Spring Security, like a basic auth username and password, and the client is misconfigured you get this error:

Caused by: org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [class org.springframework.cloud.config.environment.Environment] and content type [text/html;charset=UTF-8]

This is very misleading to the user. Since the endpoint does return a 403, it should be simple to improve the error handling for the user. Here is an example of someone running into the error on StackOverflow https://stackoverflow.com/questions/59941635/spring-boot-2-2-2-release-could-not-locate-propertysource-could-not-extract

eduanb avatar Oct 14 '20 07:10 eduanb

How to solve this?

sharkdeng avatar Sep 18 '23 10:09 sharkdeng

This problem usually appears when form login is enabled in the config server, which is often the case as the auto-configured SecurityFilterChain has form login enabled. When the config client sends the wrong credentials, the server will then respond with the HTML for the login page, which the client does not know how to handle.

If you don't need form login in the config server, you can disable it to solve the issue.

hpoettker avatar Oct 12 '23 16:10 hpoettker