Skip to content

Conversation

stuqdog
Copy link
Member

@stuqdog stuqdog commented Nov 6, 2023

Major changes

When there is no response to a file upload, throw the appropriate gRPC error.

Stacktrace (in relevant part) before change:

...
  File "/opt/homebrew/lib/python3.11/site-packages/viam/app/data_client.py", line 682, in _file_upload
    assert response is not None
           ^^^^^^^^^^^^^^^^^^^^

Stacktrace (in relevant part) after change:

  File "/opt/homebrew/lib/python3.11/site-packages/viam/app/data_client.py", line 680, in _file_upload
    await stream.recv_trailing_metadata()  # causes us to throw appropriate gRPC error.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/grpclib/client.py", line 484, in recv_trailing_metadata
    self._raise_for_grpc_status(status, message, details)
  File "/opt/homebrew/lib/python3.11/site-packages/grpclib/client.py", line 345, in _raise_for_grpc_status
    raise GRPCError(status, message, details)
grpclib.exceptions.GRPCError: (<Status.UNKNOWN: 2>, 'no robot part found', None)

@stuqdog stuqdog requested a review from a team as a code owner November 6, 2023 13:37
@stuqdog stuqdog requested review from njooma and cheukt November 6, 2023 13:37
Copy link
Member

@cheukt cheukt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do this in other parts of the SDK as well? e.g. I think upload_module_file has this too

@stuqdog stuqdog requested a review from cheukt November 7, 2023 13:18
Copy link
Member

@cheukt cheukt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@njooma njooma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One q

response = await stream.recv_message()
assert response is not None
if not response:
await stream.recv_message() # causes us to throw appropriate gRPC error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do recv_trailing_metadata in the other two functions, but recv_message here. Any difference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for catching that! Mistake on my part, it should be recv_trailing_metadata :) Fixed!

@stuqdog stuqdog merged commit fd47f61 into viamrobotics:main Nov 13, 2023
@stuqdog stuqdog deleted the return-server-error-in-data-client branch November 13, 2023 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants