We're currently using thrift for developing our micro-services. When I recently came across this below issue.
Assume below is the thrift contract for Summary Object and there is an API which gets and updates summary using the summary object passed.
Version - 1.0
struct Summary {
1: required string summaryId,
2: required i32 summaryCost
}
Summary getSummary(1: string summaryId);
void updateSummary(1: Summary summary);
Now let's say there are 5 services which are using this 1.0 contract of Summary.
In the next release we add another Object called a list of summaryvalues.
So the new contract would look like
Version - 2.0
struct Summary {
1: required string summaryId,
2: required i32 summaryCost,
3: optional list<i32> summaryValues
}
Summary getSummary(1: string summaryId);
void updateSummary(1: Summary summary);
- So when this below list is populated, we save the list of values
summaryValues
aganist thatsummaryId
. - And when the client sends this list as
null
we remove the existing values saved for that 'summaryId`.
Now the problem occurs when other services which are using OLDER version of the thrift contract (Version 1.0) try to call getSummary and updateSummary.
The intention of the Older Client by calling updateSummary was to set another value for summaryCost
. However since this client doesn't contain the object summaryValues
it sends the Summary object with summaryValues
as null to Server.
This is resulting in the Server removing all existing values of summaryValues
for that summaryId
.
Is there a way to handle this in thrift? The isSet() Methods don't work here, as they try to perform a simple null check.
Every time we release a newer client with modification to existing objects, we're having to forcefully upgrade client versions of other servers even though the change is not related to them.