Today the malformed utf8 enforcement exists to different degrees in the different languages (and even depending on the syntax of the .proto file), but its not semantically intended that a `string` field should be used for non-utf8 data in any language. It should be assumed that a serialized message with a map<string, ?> where the keys are non-utf8 may start to parse-fail in some future release of Protobuf.
Unfortunately bytes as a map key isn't allowed due to obscure technical concerns related to some non-C++ languages and the JSON representation, and we don't have an immediate plan to relax that.
Realistically your options are:
- Keep doing what you're doing, only ever keep these messages in C++ and binary wire encoding, ignore the warnings, know that it might stop working if a future release of protobuf
- Make your key data be valid utf8 strings instead (eg, use a base64 encoding of the digest instead of the raw digest bytes)
- Use repeated of a message with a key and value field instead of a map, and use your own struct as the in-memory representation when processing (move the data into/out of a STL map at the parse/serialization boundaries instead).
Sorry there's not a more trivial fix available for this usecase!