conjure-java-runtime icon indicating copy to clipboard operation
conjure-java-runtime copied to clipboard

Undertow endpoints cannot deserialize optional header params sent by Feign clients

Open pkoenig10 opened this issue 5 years ago • 4 comments

What happened?

A service is exposing a Conjure Undertow endpoint with an Optional<AuthHeader> header parameter. A Conjure Feign client calls this endpoint with an Optional.empty() value and receives a 400 because this parameter fails to deserialize.

What did you want to happen?

The request from the client should have succeeded.

Details

This is related to https://github.com/palantir/conjure-java-runtime/issues/790.

This request works against a Jersey service because Jersey will return null if an exception is thrown while deserializing an empty string.

pkoenig10 avatar Nov 20 '19 22:11 pkoenig10

I can provide a link to an internal CI build that demonstrates this behavior.

pkoenig10 avatar Nov 20 '19 22:11 pkoenig10

Same problem as https://github.com/palantir/conjure-java-runtime/issues/1331#issuecomment-556465421

The conjure spec requires optional headers to be absent from the request to deserialize into an empty optional, otherwise we would not be able to differentiate between a present optional of an empty string, and and absent optional.

carterkozak avatar Nov 20 '19 22:11 carterkozak

Right. Ideally we would fix #790. Although it doesn't seems like we are planning to do that.

Also, without a server-side fix, servers with optional parameters cannot switch to using Undertow endpoints because they cannot guarantee that they will not break existing clients.

The only reason optional parameters work at all today is because both clients and servers do not adhere to the spec.

pkoenig10 avatar Nov 20 '19 22:11 pkoenig10

Just ran into this in another internal product.

a-k-g avatar May 20 '20 09:05 a-k-g