You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the Undertow service generator, using a return type that is an alias of binary type results in an incorrect content-type header being added to the response. In this situation we'd expect to receive the content-type of application/octet-stream but instead receive application/json which results in errors in the conjure client like the following:
Unsupported Content-Type: {received=application/json, supportedEncodings=[EncodingDeserializerContainer{encoding=BinaryEncoding{application/octet-stream}, deserializer=InputStreamDeserializer{}}]}
com.palantir.logsafe.exceptions.SafeRuntimeException: Unsupported Content-Type: {received=application/json, supportedEncodings=[EncodingDeserializerContainer{encoding=BinaryEncoding{application/octet-stream}, deserializer=InputStreamDeserializer{}}]}
at com.palantir.conjure.java.dialogue.serde.ConjureBodySerDe$EncodingDeserializerRegistry$1.deserialize(ConjureBodySerDe.java:298)
at com.palantir.conjure.java.dialogue.serde.ConjureBodySerDe$EncodingDeserializerRegistry.deserialize(ConjureBodySerDe.java:257)
at com.palantir.dialogue.futures.DialogueDirectTransformationFuture.onSuccess(DialogueDirectTransformationFuture.java:103)
In this situation, I'd want/expect the content-type to be appropriately set to application/octet-stream when using an endpoint return type of a binary alias.
Just thinking out loud, there are probably a few different ways to go about this. We would de-alias binary alias return types in the Undertow interfaces to be consistent with the other generators, though that could cause compile breaks in consumers. Additionally, I'm guessing we could add additional logic into the ConjureBodySerDe class to detect and handle this situation.
The text was updated successfully, but these errors were encountered:
What happened?
When using the Undertow service generator, using a return type that is an alias of binary type results in an incorrect content-type header being added to the response. In this situation we'd expect to receive the content-type of
application/octet-stream
but instead receiveapplication/json
which results in errors in the conjure client like the following:For other service generators, like Dialogue and Jersey, it looks like binary alias return types are de-aliased during interface generation so that we don't end up using the binary alias type at all for return types and don't run into this issue. However, for the Undertow interfaces, we end up using the binary alias return type and I'm guessing we end up falling back to the default
application/json
in https://github.com/palantir/conjure-java/blob/develop/conjure-java-undertow-runtime/src/main/java/com/palantir/conjure/java/undertow/runtime/ConjureBodySerDe.java#L119-L137.What did you want to happen?
In this situation, I'd want/expect the content-type to be appropriately set to
application/octet-stream
when using an endpoint return type of a binary alias.Just thinking out loud, there are probably a few different ways to go about this. We would de-alias binary alias return types in the Undertow interfaces to be consistent with the other generators, though that could cause compile breaks in consumers. Additionally, I'm guessing we could add additional logic into the
ConjureBodySerDe
class to detect and handle this situation.The text was updated successfully, but these errors were encountered: