Open ash211 opened 2 years ago
This has been a long standing issue with lots of prior discussion, see https://github.com/palantir/conjure-java/issues/1812.
Looks like we previously thought the wire spec does specify JSON serialization: https://github.com/palantir/conjure-java/issues/1812#issuecomment-1138931195 I'll add a clarifying example to the wire format doc.
BLUF: we don't specify the wire format for complex error parameters, and conjure-java and conjure-typescript are behaving differently. We need to determine correct wire format here, and then update the language implementations to match.
Here is the current wire spec for error parameters: https://github.com/palantir/conjure/blob/master/docs/spec/wire.md#55-conjure-errors
Unfortunately, the serialization format for these parameters is under-specified, and there's currently a mismatch between what conjure-java generates, and what conjure-typescript expects. Conjure-java effectively casts complex types to strings and sends the data as a string, whereas conjure-typescript generates .d.ts types expecting the complex types. Instead, it gets strings. This manifests as broken typescript code (at runtime!), and a difficulty accessing complex error parameters from typescript.
Example
Given this yml error definition:
The conjure-java library generates errors that look like this (from chrome network tab):
Note that the sha256s are strings, and not sets/maps.
The conjure-generated typescript definition expects these to be sets/maps, and not strings:
To handle this, currently FE typescript code is handling both types, outside of the conjure generator.
Sample: