Merge ~andersson123/autopkgtest-cloud:fix-package-page-nonexistent-package into autopkgtest-cloud:master

Proposed by Tim Andersson
Status: Needs review
Proposed branch: ~andersson123/autopkgtest-cloud:fix-package-page-nonexistent-package
Merge into: autopkgtest-cloud:master
Diff against target: 42 lines (+12/-1)
2 files modified
charms/focal/autopkgtest-web/webcontrol/browse.cgi (+3/-1)
charms/focal/autopkgtest-web/webcontrol/helpers/exceptions.py (+9/-0)
Reviewer Review Type Date Requested Status
Brian Murray Disapprove
Skia Approve
Review via email: mp+462703@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Skia (hyask) wrote :

Looking good!

review: Approve
Revision history for this message
Brian Murray (brian-murray) wrote :

Thinking about this some more I'm not sure what is the worst end user experience.

A) Mistype a package name and get a web page with no test results.

OR

B) Properly type a package name and get a 404.

I'm leaning towards B being the worst end user experience since at least with A I can click on the LP url and get a nicely formatted 404. Especially, since case A also will not show any releases which is a pretty good indicator you misspelled the package name.

review: Disapprove
Revision history for this message
Tim Andersson (andersson123) wrote :

Okay, understood, so, should I close this MP? And the related bug?

Revision history for this message
Brian Murray (brian-murray) wrote :

Well ideally the autopkgtest-web workers would know what is and is not a package and then could either return a 404 or a page saying the package has no tests. However, I think that makes the bug a lower priority given the difficulty of it.

Revision history for this message
Tim Andersson (andersson123) wrote :

How about 2 outcomes?

outcome 1:
- user types in a package which exists in launchpad but has no previous results - is greeted with a page stating as such
- user types in a package which doesn't exist in launchpad but does have previous results - is greeted with the normal package browsing page
- user types in a package which doesn't exist in launchpad and has no previous results - we then assume the package doesn't exist and we tell the user as such

The above solution is quite easy I believe. Let me know what you think. If you like that solution I can go ahead and implement it.

Revision history for this message
Tim Andersson (andersson123) wrote :

waiting on feedback for this MP.

Unmerged commits

ba44a14... by Tim Andersson

fix: web: Don't show package pages for packages that don't exist

Fixes bug LP: #2058059

Succeeded
[SUCCEEDED] pre_commit:0 (build)
[SUCCEEDED] unit_tests:0 (build)
[SUCCEEDED] build_charms:0 (build)
13 of 3 results

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
index 810163d..4352154 100755
--- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi
+++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
@@ -12,7 +12,7 @@ from wsgiref.handlers import CGIHandler
1212
13import flask13import flask
14from helpers.admin import select_abnormally_long_jobs14from helpers.admin import select_abnormally_long_jobs
15from helpers.exceptions import RunningJSONNotFound15from helpers.exceptions import NonExistentPackage, RunningJSONNotFound
16from helpers.utils import get_all_releases, get_supported_releases16from helpers.utils import get_all_releases, get_supported_releases
17from werkzeug.middleware.proxy_fix import ProxyFix17from werkzeug.middleware.proxy_fix import ProxyFix
1818
@@ -279,6 +279,8 @@ def package_overview(package, _=None):
279 ):279 ):
280 arches.add(row[3])280 arches.add(row[3])
281 results.setdefault(row[2], {})[row[3]] = human_exitcode(row[1])281 results.setdefault(row[2], {})[row[3]] = human_exitcode(row[1])
282 if not results:
283 raise NonExistentPackage(package)
282284
283 running_info = dict(285 running_info = dict(
284 (k, v) for (k, v) in get_running_jobs().items() if k == package286 (k, v) for (k, v) in get_running_jobs().items() if k == package
diff --git a/charms/focal/autopkgtest-web/webcontrol/helpers/exceptions.py b/charms/focal/autopkgtest-web/webcontrol/helpers/exceptions.py
index e94164e..c3a22d9 100644
--- a/charms/focal/autopkgtest-web/webcontrol/helpers/exceptions.py
+++ b/charms/focal/autopkgtest-web/webcontrol/helpers/exceptions.py
@@ -15,6 +15,15 @@ class RunningJSONNotFound(FileNotFoundError):
15 return 50015 return 500
1616
1717
18class NonExistentPackage(Exception):
19 def __init__(self, package):
20 super().__init__("Package %s doesn't exist." % package)
21 self._code = 404
22
23 def exit_code(self):
24 return self._code
25
26
18class WebControlException(Exception):27class WebControlException(Exception):
19 def __init__(self, message, exit_code):28 def __init__(self, message, exit_code):
20 super().__init__(message)29 super().__init__(message)

Subscribers

People subscribed via source and target branches