Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1228·protobuf

proto: annotate errors regarding invalid UTF-8 with the relevant field

Author: nicolasparadaCreated Oct 22, 2020Updated Feb 17, 2026

Is your feature request related to a problem? Please describe. string field contains invalid UTF-8 errors while marshaling using the new Go proto library google.golang.org/protobuf, but it's too difficult to debug since one doesn't know which field has the problem.

Describe the solution you'd like Add the field name to the error message. Something like:

string field "foo" contains invalid UTF-8

Describe alternatives you've considered Looks like the issue is related to directly converting from a slice of bytes to a string.

string([]byte)

If that's the case, one could potentially triage that, but the field name would much more helpfull.

Additional context This is using the new golang google.golang.org/protobuf module at v1.25.0 at least.

Source: golang/protobuf

View original on GitHubView discussion on GitHub