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 db?
Asked
Active
Viewed 172 times
0

noob-dev
- 59
- 1
- 7
-
Do you perform this reverse mapping on your server implementation? If so, you could fail the RPC with whatever code you see fit. – Easwar Swaminathan Feb 15 '23 at 18:43
-
1Yes. But I wanted to understand what 'Unrecoverable data loss or corruption' meant. – noob-dev Feb 16 '23 at 23:25
-
In the scenario you describe, the data loss certainly doesn't seem "unrecoverable." I would probably serve INTERNAL in this case. – Richard Belleville Feb 22 '23 at 19:00