-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proto Error returned when using aetest context -- proto: invalid UTF-8 string
#136
Comments
Thank you for the bug report, I can reproduce this. This appears to be due to golang/protobuf#499, which changes how the protobuf library handles strings: they are now expected to be valid UTF-8 strings. Unfortunately, the way we encode protos in other protos in the datastore library doesn't produce valid UTF-8 strings. |
This is also the reason our tests on Travis just started failing. |
Thanks for getting back to me on this, @sbuss! As a temporary resolution, I have added this to our deploy scripts |
I'm not familiar with data store, but IIUC, it is the user who provides the proto message that is to be marshaled and unmarshaled. For your use-case, are you able to switch the proto field type from |
I just merged golang/protobuf#616, which should help identify which field is problematic. |
Thanks, @dsnet. The error is now:
|
Is that a field where the proto type can be easily switch from |
I have been experimenting with fixing this, and it looks like just replacing @egag Can you try this? pushd $(dirname $(which gcloud))/../platform/google_appengine/google/appengine/datastore
sed -i "s/query.Encode()/'devindex'/" datastore_stub_util.py
popd
go get -u github.com/golang/protobuf I'm not 100% sure that this will work, but I'd like to get feedback from a real-world use case. |
@sbuss This did fix this error for me! Unfortunately, now I get this error: Is this happening because of a particular field on the That did fix the error from the query though. |
I'm also seeing Anyone know what aetest and/or dev_appserver.py will be missing in terms of environment that will make the difference? I tried this:
but made no difference. |
@egag Well, that's progress :) I'm pretty sure that if you use #141 the error will disappear: pushd $GOPATH/src/google.golang.org/appengine && git fetch && git checkout fixdatastore && popd If that's the case, then that's going to make fixing it in prod a little more difficult for me, but at least I'll know for sure that that's the right approach. |
@lukebjerring I think that's happening because your system's The error message does make it sound like it's a locale issue, but it's actually because |
@sbuss I will give that a try. I really appreciate your help with this! |
@sbuss |
@egag unfortunately, you can no longer store binary data in the StringValue. You might be doing something like this:
But now you need to do this:
My biggest concern is that you've stored invalid UTF-8 strings in datastore which you'll be unable to retrieve using the latest |
@sbuss Interesting. That's unfortunate. Is binary data no longer supported? It's still listed in the docs Or is there a more appropriate way to store binary data than in a slice of bytes? This error is occurring when I use datastore.Put for an entity with a property of type |
@lukebjerring try adding this to your docker file (after downloading all dependencies): |
@egag thanks, did something similar:
|
@egag Can you show me what your code does in as much detail as you're able? I suspect it's something akin to the following, but I want to be sure. k := datastore.NewKey(ctx, "Data", "invalidbytes", 0, nil)
b := "\xa0\x01" // \xa0 is an invalid utf-8 byte
_, err := datastore.Put(ctx, k, b) This indicates we might actually be able to fix this instead of pushing back against protobuf, but I need to sync up with someone on the datastore team to be sure. |
@sbuss Great! This should reproduce the error:
I think it's because the byte slice is treated as a string under the covers. |
Much appreciated! For reference/if others run into this, this fixed the original issue:
|
golang/appengine#136 has been fixed so we don't need the hack. This change only stops to pin protobuf in new Go workspace. If your protobuf pkg has already been pinned, you'd need to manually: cd $GOPATH/src/github.com/golang/protobuf && git checkout master && git pull Or if you use Docker, simply remove the Docker instance.
The error is set inside the
Iterator
on the call todatastore.Query.Run
.It is initially returned by the call to
internal.Call
line 534 indatastore/query.go
Which returns the error at the call to
proto.Unmarshall
line 534 (also coincidently lol) ininternal/api.go
The error is:
proto: invalid UTF-8 string
This occurs with the most recent version of
github.com/golang/protobuf
which was updated in response to this issue: golang/protobuf#484The following code reproduces the issue:
The text was updated successfully, but these errors were encountered: