Skip to content

feat: show server error message in push#647

Merged
JoanFM merged 3 commits intomainfrom
feat-push-show-error
Oct 19, 2022
Merged

feat: show server error message in push#647
JoanFM merged 3 commits intomainfrom
feat-push-show-error

Conversation

@alaeddine-13
Copy link
Copy Markdown
Member

Show the error message coming from the server in push, if the code is 403

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 18, 2022

Codecov Report

Merging #647 (b744c2c) into main (6a532b3) will decrease coverage by 0.02%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##             main     #647      +/-   ##
==========================================
- Coverage   84.97%   84.95%   -0.03%     
==========================================
  Files         133      133              
  Lines        6728     6731       +3     
==========================================
+ Hits         5717     5718       +1     
- Misses       1011     1013       +2     
Flag Coverage Δ
docarray 84.95% <66.66%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
docarray/array/mixins/io/pushpull.py 91.80% <66.66%> (-0.64%) ⬇️
docarray/array/mixins/sample.py 84.61% <0.00%> (-7.70%) ⬇️
docarray/array/queryset/lookup.py 76.08% <0.00%> (-2.18%) ⬇️
docarray/array/storage/weaviate/find.py 83.54% <0.00%> (-1.27%) ⬇️
docarray/array/mixins/find.py 87.62% <0.00%> (-1.04%) ⬇️
docarray/array/mixins/traverse.py 95.04% <0.00%> (+4.13%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

if response.ok:
return response.json()['data']
else:
if response.status_code == 403:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

403 seems a magic number, lets use a constant

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jina-ai/team-hubble @delgermurun @mapleeit these constants should come from hubble-sdk

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does it make sense to use http.HTTPStatus.FORBIDDEN here?

It's standard http status code and libarary/http already provides that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The 403 error is not the only one. How about trying to get a message from every error response?
All errors should have a message, but checking for its existence is also helpful to have.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

applied

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree with @delgermurun

For all the status code >= 400, we should adopt the same strategy, which is printing the error message out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

@delgermurun delgermurun left a comment

Choose a reason for hiding this comment

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

LGTM

return response.json()['data']
else:
if response.status_code >= 400 and 'readableMessage' in response.json():
response.reason = response.json()['readableMessage']
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

u should use HTTPStatus for somehing. There must be some constant from there, 400 seems magic to me

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would've used it if it was an equal check (==).
I think it is more readable to use the actual number in comparison (it just means failed response).
The requests library does the same actually
image

@JoanFM JoanFM merged commit 0174738 into main Oct 19, 2022
@JoanFM JoanFM deleted the feat-push-show-error branch October 19, 2022 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants