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

Graceful handling of API HTTP 4xx responses #1109

Open
1 task
codificat opened this issue Apr 25, 2022 · 3 comments
Open
1 task

Graceful handling of API HTTP 4xx responses #1109

codificat opened this issue Apr 25, 2022 · 3 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/user-experience Issues or PRs related to the User Experience of our Services, Tools, and Libraries.

Comments

@codificat
Copy link
Member

Problem statement

I ran a quick test of running thamos on an unsupported platform (FreeBSD), and I received this:

pep@freebsd:~/cli-examples $ thamos advise
2022-04-22 16:13:11,472 [3687] WARNING  thamos: Development dependencies will not be considered during the resolution process - see https://thoth-station.ninja/j/no_dev
2022-04-22 16:13:11,472 [3687] INFO     thamos.lib: Using Pipenv files to manage dependencies located in '/usr/home/pep/cli-examples'
2022-04-22 16:13:11,472 [3687] INFO     thamos.lib: Submitting Pipfile.lock as a base for user's stack scoring - see https://thoth-station.ninja/j/user_stack
2022-04-22 16:13:12,474 [3687] INFO     thamos.lib: Using 'latest' recommendation type - see https://thoth-station.ninja/recommendation-types/
2022-04-22 16:13:12,475 [3687] INFO     thamos.lib: Performing static analysis of sources to gather library usage
2022-04-22 16:13:12,676 [3687] ERROR    thamos: (400)
Reason: BAD REQUEST
HTTP response headers: HTTPHeaderDict({'server': 'gunicorn', 'date': 'Fri, 22 Apr 2022 16:13:13 GMT', 'content-type': 'application/problem+json', 'content-length': '179', 'access-control-allow-origin': '*', 'x-thoth-version': '0.34.13', 'x-user-api-service-version': '0.34.13+messaging.0.16.0.storages.0.71.1.common.0.36.0.python.0.16.9', 'set-cookie': '99770cb82864be05282857f803e02327=b78e61ba4533d9d3918951ac9b762e96; path=/; HttpOnly; Secure; SameSite=None'})
HTTP response body: b'{\n  "detail": "\'freebsd-13.0-RELEASE-amd64\' is not one of [\'linux-x86_64\'] - \'runtime_environment.platform\'",\n  "status": 400,\n  "title": "Bad Request",\n  "type": "about:blank"\n}\n'

I believe that it would be good to provide a more user-friendly error message here; at first look, this might look as a bug in the code (either client or server side), and it might not be clear enough, for this case, that the resolver will not work on this platform and why.

High-level Goals

As a user, I would like to see friendly messages that help me quickly identify the causes of problems that result in "bad requests", so that I can better understand what's happening and how can I proceed.

Proposal description

Provide a friendly message.

At a minimum, it might be enough to present the response body (and potentially relevant header fields) in a nicely formatted way, e.g. for the example above:

Title: Bad Request
Detail: 'freebsd-13.0-RELEASE-amd64' is not one of ['linux-x86_64'] - 'runtime_environment.platform'

Beyond that, it would be helpful to automatically identify a few "expected" or common problems and provide a custom message for them, e.g.

Title: Unsupported platform
Detail: 'freebsd-13.0-RELEASE-amd64' is not one of the currently supported platforms, please see XXX

and potentially point to https://khemenu.thoth-station.ninja/api/v1/ui/#/PythonPackages/get_python_platform or even get its contents and print them nicely.

Additional context

See also thoth-station/user-api#1595 for current inconsistent 400 HTTP responses, depending on what triggered them, as this might be something to keep in mind when implementing the handling on the client side.

Acceptance Criteria

  • A user friendly message appears after HTTP 4xx API responses
@codificat
Copy link
Member Author

/sig user-experience
/kind feature
/priority important-soon

@sesheta sesheta added sig/user-experience Issues or PRs related to the User Experience of our Services, Tools, and Libraries. kind/feature Categorizes issue or PR as related to a new feature. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Apr 25, 2022
@sesheta
Copy link
Member

sesheta commented Jul 24, 2022

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@sesheta sesheta added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 24, 2022
@mayaCostantini
Copy link
Contributor

/remove-lifecycle stale
/lifecycle frozen

@sesheta sesheta added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 25, 2022
@codificat codificat moved this to 🆕 New in Planning Board Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/user-experience Issues or PRs related to the User Experience of our Services, Tools, and Libraries.
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants