GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: error message return from api by HemangChothani · Pull Request #235 · googleapis/python-storage

This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Conversation

@HemangChothani

@HemangChothani HemangChothani commented Aug 7, 2020

Copy link
Copy Markdown
Contributor

Fixes #224 🦕

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@HemangChothani
feat(storage): error message retyrn from api
d18c3b1
@HemangChothani
HemangChothani requested review from frankyn and tseaver August 7, 2020 07:45
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 7, 2020
@tseaver

tseaver commented Aug 10, 2020

Copy link
Copy Markdown
Contributor

Nit: please drop the (apiname) part of the prefix for your commit summaries. That convention made sense in the mono-repository, but post-repo-split, it is redundant and cluttery.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver tseaver changed the title feat(storage): error message return from api feat: error message return from api Aug 10, 2020
tseaver
tseaver reviewed Aug 10, 2020
View reviewed changes
Comment thread google/cloud/storage/blob.py Outdated
if response.text:
error_message = response.text + ": " + str(error)
else:
error_message = "unknown error: " + str(error)

@tseaver tseaver Aug 10, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd prefer not to add the prefix here. @frankyn WDYT?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@frankyn frankyn Aug 11, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Could you clarify the difference between response.text and error (add comments I suspect others will ask this question when reviewing the code in the future).

I also think repsonse.text could be added to the line below when constructing the message value instead of this conditional.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@HemangChothani HemangChothani Aug 13, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@frankyn I have added condition here to match the method which is responsible for other http responses and errors declared in pytho-api-core.exceptions.from_http_response you can find here https://github.com/googleapis/python-api-core/blob/622931721ce34839d630aa1e974c7d8f47b5d25e/google/api_core/exceptions.py#L390-L411

response.text: gives the actual reason of error
str(error): gives ('Request failed with status code', 404(Error Code), 'Expected one of', <HTTPStatus.OK: 200>, <HTTPStatus.PARTIAL_CONTENT: 206>)

I think here we can remove str(error) as it's not meaning full for the users, also not included in other http methods from python-api-core as mention above.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@HemangChothani HemangChothani Aug 19, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@frankyn I think it's necessary to add actual reason in error message, Ex: in the #249 issue user share a stack trace of error but it's hard to debug as actual reason isn't there in message.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@frankyn frankyn Aug 24, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think I need to pull in @andrewsg on this one when he has a moment.

Andrew do you have guidance on raising the actual error that occurred in this case?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@andrewsg andrewsg Aug 24, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If I understand correctly, the problem here is the same as I've observed elsewhere where the API responds with human-readable text which is not converted into a specific error message by our client library. Prepending this human-readable text does make sense though I'm neutral on whether we should include the "unknown error" prepending in the else case.

We should make sure that the traceback still includes the original function call that caused the error.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@frankyn frankyn Aug 25, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks @andrewsg.

I don't see the value of unknown error: and could be confusing otherwise. Please only preppend response.text when it's available. Remove unknown error:.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tseaver
Merge branch 'master' into storage_issue_224
1820f55
frankyn
frankyn suggested changes Aug 11, 2020
View reviewed changes
Comment thread google/cloud/storage/blob.py Outdated
if response.text:
error_message = response.text + ": " + str(error)
else:
error_message = "unknown error: " + str(error)

@frankyn frankyn Aug 11, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Could you clarify the difference between response.text and error (add comments I suspect others will ask this question when reviewing the code in the future).

I also think repsonse.text could be added to the line below when constructing the message value instead of this conditional.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
HemangChothani added 4 commits August 13, 2020 14:40
@HemangChothani
Merge branch 'master' of https://github.com/googleapis/python-storage …
970ece9
…into storage_issue_224
@HemangChothani
Merge branch 'storage_issue_224' of https://github.com/q-logic/python…
ae8de9d
…-storage into storage_issue_224
@HemangChothani
feat: add comment for clarification
57a1358
@HemangChothani
Merge branch 'master' of https://github.com/googleapis/python-storage …
dc9f4ff
…into storage_issue_224
@priyanshujain priyanshujain mentioned this pull request Aug 19, 2020
BadRequest from gcs APIs while downloading file cotent to file_obj #249
Closed
@HemangChothani
Merge branch 'master' of https://github.com/googleapis/python-storage …
aa332f6
…into storage_issue_224
@product-auto-label product-auto-label Bot added the api: storage Issues related to the googleapis/python-storage API. label Aug 21, 2020
HemangChothani and others added 3 commits August 25, 2020 11:04
@HemangChothani
Merge branch 'master' of https://github.com/googleapis/python-storage …
07c2478
…into storage_issue_224
@frankyn
Merge branch 'master' into storage_issue_224
39f00df
@HemangChothani
fix: remove unknown error
562abfd
frankyn
frankyn approved these changes Aug 26, 2020
View reviewed changes
@frankyn
frankyn merged commit a8de586 into googleapis:master Aug 26, 2020
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
@HemangChothani @tseaver
@frankyn @cojenco
feat: error message return from api (googleapis#235)
5d70a1b
* feat(storage): error message retyrn from api

* feat: add comment for clarification

* fix: remove unknown error

Co-authored-by: Tres Seaver <[email protected]>
Co-authored-by: Frank Natividad <[email protected]>
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
@HemangChothani @tseaver
@frankyn @cojenco
feat: error message return from api (googleapis#235)
eaadb59
* feat(storage): error message retyrn from api

* feat: add comment for clarification

* fix: remove unknown error

Co-authored-by: Tres Seaver <[email protected]>
Co-authored-by: Frank Natividad <[email protected]>
@release-please release-please Bot mentioned this pull request Jan 12, 2022
chore(main): release 3.0.0 #688
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

3 more reviewers
@tseaver tseaver tseaver left review comments
@andrewsg andrewsg andrewsg left review comments
@frankyn frankyn frankyn approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: storage Issues related to the googleapis/python-storage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Except with error messages returned from the API

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@HemangChothani @tseaver @andrewsg @frankyn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.