No Converter found for ByteString to String
See original GitHub issueDescribe the bug
When I’m using spring cloud openfeing with a custom configuration that has injected properties values with @Value annotation that are obtained from google secret manager I’m getting the following error
nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [com.google.protobuf.ByteString$LiteralByteString] to type [java.lang.String]"}
I made a example project with the use of this type of configuration but it does not work cause I do not have a gcp subscription, but you can get the idea.
application.properties AUTH_CREDENTIALS=${sm://secret}
As a summary I have the configuration file for feign similar to the following one
@Value("${AUTH_CREDENTIALS}") //These credentials are store in this way username:password so I need to encode and add to header
private String authCredentials;
@Bean
public RequestInterceptor basicAuthRequestInterceptor(){
return new CustomBasicAuthRequestInterceptor(authCredentials);
}
An a feign client that uses the configuration
@FeignClient(value = "restClient", url = "${REST_URL}", configuration = CustomBasicAuthConfiguration.class)
public interface RestClient {
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
String request();
}
The request interceptor
private String headerValue;
public CustomBasicAuthRequestInterceptor(String authCredentials) {
this(authCredentials, StandardCharsets.UTF_8);
}
public CustomBasicAuthRequestInterceptor(String authCredentials, Charset charset) {
this.headerValue = "Basic " + new String(Base64.getEncoder().encode(authCredentials.getBytes(charset)));
}
@Override
public void apply(RequestTemplate requestTemplate) {
requestTemplate.header("Authorization", headerValue);
}
When I’m using this way I get the exception described above, but when I annotated with @Component I don’t get the exception. I prefer the first way because I have several feign clients and this one needs this configuration.
Also in the example project you will find a workaround that was answered here
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Hi @danielalejandrin and @damienburke, the latest version of this project solves this problem and you don’t need to define a converter, but it’s not released yet. My suggestion is you can keep the workaround for now and change it when we official release the next version.
Hi @bjeon-bakkt, you can try 3.4.0. Could you post a sample project which reproduce the issue in a Github repo?