AlikElzin-kilaka
AlikElzin-kilaka

Reputation: 36001

"No field key specified for" warning with Thrift generator

Getting the warning:

No field key specified for bytes, resulting protocol may have conflicts or not be backwards compatible!

When trying to generate the following line:

void uploadChunk(binary bytes)

I tried several other param names and couldn't find info on this warning using Google search.

Ideas?

Upvotes: 1

Views: 2175

Answers (3)

afelt
afelt

Reputation: 99

To add on to the answer from JensG which is correct, the reason that auto-assigned numbering of your fields can lead to incompatibility is explained more below:

If a server is running a Thrift interface with three unnumbered parameters, and a client is running an older version of that interface with only two unnumbered parameters, the server may not correctly correlate the values offered to the parameters available. If they are numbered, there is no confusion. Numbering is a good idea to support what is called schema evolution.

Upvotes: 2

JensG
JensG

Reputation: 13411

The solution to apply a numeric field key (or field ID) is absolutely correct.

Thrift allows for fields without an ID for the sake of compatibility. Internally, a negative number is assigned to such fields. However, it is strongly recommended to specify a field ID > 0, because the automatically assigned numbers may change if you include more members before a given member, or if you shuffle members around, both leading to incompatibility due to differently auto-numbered fields.

And that's exactly the reason for the warning.

Upvotes: 1

AlikElzin-kilaka
AlikElzin-kilaka

Reputation: 36001

Oh, I added 1: before binary and the warning disappeared:

void uploadChunk(1:binary bytes)

There's probably some language that Thrift generates that needs a field key and 1 is the field key.

Upvotes: 5

Related Questions