gRPC DATA_LOSS error code usage clarification

383 Views Asked by At

I'm working on a gRPC API that has a database with an endpoint to return a record back to the consumer. One of the columns is an enum string {X|Y|Z}. When returning the record, I reverse map the enum to an int. IF someone edits the data to maliciously insert 'M' into the column, the reverse mapping fails. In this case, what's the gRPC error code that needs to be returned? DATA_LOSS or FAILED_PRECONDITION or INTERNAL ? As per the Unrecoverable data loss or corruption.. Does this mean, data is not longer recoverable by any means or the API was not able to act based on the data it fetched from the database?

1

There are 1 best solutions below

0
Margach Chris On

This error comes from having a mismatch in the field numbers or fields of the protobuf file used on the client and the server.

Either you updated the client protobuf and forgot to update the server protobuf or the other way round.