Skip to content
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

datastore v1beta3 doesn't handle errors properly #1617

Closed
pcostell opened this issue Mar 15, 2016 · 5 comments
Closed

datastore v1beta3 doesn't handle errors properly #1617

pcostell opened this issue Mar 15, 2016 · 5 comments
Assignees
Labels
api: datastore Issues related to the Datastore API.

Comments

@pcostell
Copy link
Contributor

In Datastore v1beta3, the error response is a serialized proto message Status. However, the error handling currently tries to decode it, which can fail with a unicode error.


  File "./main.py", line 20, in lookup
    print(client.get(key))
  File "/Users/pcostello/.local/virtualenvs/gcloud-permissions-v1beta3/src/gcloud/gcloud/datastore/client.py", line 248, in get
    deferred=deferred)
  File "/Users/pcostello/.local/virtualenvs/gcloud-permissions-v1beta3/src/gcloud/gcloud/datastore/client.py", line 289, in get_multi
    transaction_id=transaction and transaction.id,
  File "/Users/pcostello/.local/virtualenvs/gcloud-permissions-v1beta3/src/gcloud/gcloud/datastore/client.py", line 122, in _extended_lookup
    transaction_id=transaction_id,
  File "/Users/pcostello/.local/virtualenvs/gcloud-permissions-v1beta3/src/gcloud/gcloud/datastore/connection.py", line 197, in lookup
    _datastore_pb2.LookupResponse)
  File "/Users/pcostello/.local/virtualenvs/gcloud-permissions-v1beta3/src/gcloud/gcloud/datastore/connection.py", line 115, in _rpc
    data=request_pb.SerializeToString())
  File "/Users/pcostello/.local/virtualenvs/gcloud-permissions-v1beta3/src/gcloud/gcloud/datastore/connection.py", line 92, in _request
    raise make_exception(headers, content, use_json=False)
  File "/Users/pcostello/.local/virtualenvs/gcloud-permissions-v1beta3/src/gcloud/gcloud/exceptions.py", line 181, in make_exception
    content = content.decode('utf-8')
  File "/Users/pcostello/.local/virtualenvs/gcloud-permissions-v1beta3/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa8 in position 20: invalid start byte
@pcostell
Copy link
Contributor Author

I attached #1618 which shows what the expected response is. I can updated it and submit it if you want, but it's just a hack to show the issue.

@dhermes
Copy link
Contributor

dhermes commented Mar 16, 2016

Thanks @pcostell. We discussed this in #1466 and I added it as a TODO in #1288 but hadn't gotten to it yet.

Some good news is that googleapis-common-protos actually includes status_pb2 so we don't have to do anything extra to get it.

@pcostell
Copy link
Contributor Author

Ah I totally forgot. It seems potentially more important than I realized since now users will fail with utf-8 decoding issues with no indication of the actual error.

@dhermes
Copy link
Contributor

dhermes commented Mar 16, 2016

Yes. When reporting an error causes an error, that's a problem

@dhermes dhermes added the api: datastore Issues related to the Datastore API. label Mar 18, 2016
@pcostell
Copy link
Contributor Author

Fixed by #1638

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API.
Projects
None yet
Development

No branches or pull requests

2 participants