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

Proposed by Tim Andersson
Status: Merged
Merged at revision: 133ca4c30253ec85868f957d19a9686b7a821db7
Proposed branch: ~andersson123/autopkgtest-cloud:fix-package-page-nonexistent-package
Merge into: autopkgtest-cloud:master
Diff against target: 138 lines (+64/-30)
4 files modified
charms/focal/autopkgtest-web/webcontrol/browse.cgi (+6/-1)
charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html (+40/-21)
charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html (+12/-8)
charms/focal/autopkgtest-web/webcontrol/templates/macros.html (+6/-0)
Reviewer Review Type Date Requested Status
Skia Approve
Brian Murray Needs Fixing
Review via email: mp+462703@code.launchpad.net

Commit message

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

This commit changes the behaviour when a user tries to reach a package
or results page for a package that doesn't exist.

The results page used to throw an error stating that the package doesn't
exist, however, I think this is slightly innaccurate - the package could
exist, but we could just have no test results for it. This is infact
not really, an error, and not something we should surface *as* an error.

The behaviour, with this commit, is as follows:
On the results and package pages, if the user goes to one of these pages
for a package that doesn't exist, they get the following message:
```
Oops! Looks like this package has no previous results. The package
itself may not exist - you can check by clicking the Launchpad icon.
```

I think this is better because, a, we are no longer throwing an error,
and b, because the user can now validate the package exists by clicking
on the Launchpad icon.

Overall I think this is just an accurate representation of all the
potential possibilities when going to either of these pages with an
"invalid" package name.

There is the possibility of checking if the package exists via
Launchpad, but that'd be an http request to Launchpad every time a user
views a package or results page, which is a waste of resources, and
seems unnecessary.

Fixes bug LP: #2058059

Description of the change

This MP changes the message we surface to users when they request a package or results page for an "invalid" package, and no longer surfaces it as an error, but instead with a verbose message about the two possibilities in this scenario.

Overall, it's a small change for improved UX. It's low priority but worth taking a look at.

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.

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

This one needs more info.

Revision history for this message
Brian Murray (brian-murray) 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

This doesn't seem much different from what is currently implied from the existing page so that makes sense.

> - user types in a package which doesn't exist in launchpad but does have
> previous results - is greeted with the normal package browsing page

This is impossible. Seriously, any package for which we have results should also have a +source page in Launchpad.

> - 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

That sounds good and is what the original bug report was about.

> 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
Brian Murray (brian-murray) :
review: Needs Fixing
Revision history for this message
Tim Andersson (andersson123) wrote :

I don't think it's practical to check the launchpad link when the user is browsing. Then we'd be making a request to launchpad every single time someone views a results package, which seems very wasteful. I think the better thing is to just have a message for when a package doesn't have any previous results, keep the launchpad link there and then the user can click on it if need be. I'll implement this.

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

amended and ready for review.

Revision history for this message
Skia (hyask) :
review: Abstain
Revision history for this message
Tim Andersson (andersson123) wrote :

I've set this back to work in progress - I imagine the user page MP will get merged before this one, and this MP will need to be rebased off of that, as both MP's touch browse-results.html

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

The work mentioned in the previous comment has now been completed. This is ready for re-review

Revision history for this message
Skia (hyask) wrote :

LGTM :-)

review: Approve
Revision history for this message
Skia (hyask) wrote :

Be careful, CI is red

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

Thanks for the approval! I'll fix the CI and merge :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
2index d4891ee..a4af4d8 100755
3--- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi
4+++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
5@@ -599,7 +599,12 @@ def package_release_arch(package, release, arch, _=None):
6 test_id = get_test_id(release, arch, package)
7 if test_id is None:
8 return render(
9- "browse-error.html", error="Package does not exist", code=404
10+ "browse-results.html",
11+ package=package,
12+ release=release,
13+ arch=arch,
14+ package_results=[],
15+ title_suffix="- %s/%s/%s" % (package, release, arch),
16 )
17
18 seen = set()
19diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html
20index b6a7106..2ca3add 100644
21--- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html
22+++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html
23@@ -8,29 +8,48 @@
24 <li>{{ macros.excuses_link(package) }}</li>
25 </ul>
26
27- <table class="table" style="width: auto">
28- <tr>
29- <th />
30- {% for r in releases %}<th>{{r}}</th>{% endfor %}
31- </tr>
32-
33- {% for a in arches %}
34+ {% if package_results %}
35+ <table class="table" style="width: auto">
36 <tr>
37- <th>{{a}}</th>
38- {% for r in releases %}
39- <td class="{{ results[r][a] }}">
40- <a href="{{package}}/{{r}}/{{a}}">{{ results[r][a] }}</a>
41- </td>
42- {% endfor %}
43+ <th />
44+ {% for r in releases %}<th>{{r}}</th>{% endfor %}
45 </tr>
46- {% endfor %}
47- </table>
48
49- <hr>
50- <h3>Running tests</h3>
51+ {% for a in arches %}
52+ <tr>
53+ <th>{{a}}</th>
54+ {% for r in releases %}
55+ <td class="{{ results[r][a] }}">
56+ <a href="{{package}}/{{r}}/{{a}}">{{ results[r][a] }}</a>
57+ </td>
58+ {% endfor %}
59+ </tr>
60+
61+ {% for a in arches %}
62+ <tr>
63+ <th>{{a}}</th>
64+ {% for r in releases %}
65+ <td class="{{ results[r][a] }}">
66+ <a href="{{package}}/{{r}}/{{a}}">{{ results[r][a] }}</a>
67+ </td>
68+ {% endfor %}
69+ </tr>
70+ {% endfor %}
71+ </table>
72+
73+ <hr>
74+ <h3>Running tests</h3>
75+
76+ {% for p, info in running.items()|sort %}{{ macros.display_running_job(p, info) }}{% endfor %}
77+
78+ <h3>Queued tests</h3>
79+ {{ macros.display_queues_info(queues_info) }}
80+ {% else %}
81+ {{ macros.nonexistent_package() }}
82+ {% endif %}
83
84- {% for p, info in running.items()|sort %}{{ macros.display_running_job(p, info) }}{% endfor %}
85+ {% for p, info in running.items()|sort %}{{ macros.display_running_job(p, info) }}{% endfor %}
86
87- <h3>Queued tests</h3>
88- {{ macros.display_queues_info(queues_info) }}
89-{% endblock content %}
90+ <h3>Queued tests</h3>
91+ {{ macros.display_queues_info(queues_info) }}
92+ {% endblock content %}
93diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html
94index 2978c8c..9d15751 100644
95--- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html
96+++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html
97@@ -10,15 +10,19 @@
98 <li>{{ macros.excuses_link(package, release) }}</li>
99 </ul>
100
101- <table class="table">
102- <tr>{{ macros.set_up_results_table() }}</tr>
103+ {% if package_results %}
104+ <table class="table">
105+ <tr>{{ macros.set_up_results_table() }}</tr>
106
107- {% for row in package_results %}
108- <tr {% if row[6] in ["running", "queued"] %}class="unfinished"{% endif %}>
109- {{ macros.results_table_core(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], package, release, arch) }}
110- </tr>
111- {% endfor %}
112- </table>
113+ {% for row in package_results %}
114+ <tr {% if row[6] in ["running", "queued"] %}class="unfinished"{% endif %}>
115+ {{ macros.results_table_core(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], package, release, arch) }}
116+ </tr>
117+ {% endfor %}
118+ </table>
119+ {% else %}
120+ {{ macros.nonexistent_package() }}
121+ {% endif %}
122
123 <p>
124 To ease the browsing of logs, you can use <a href="{{ url_for('static', filename='logs-viewer.user.js') }}">this userscript</a> with any extension supporting that, like <a href="https://www.tampermonkey.net/">TamperMonkey</a>.
125diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html
126index d92d357..0a585c5 100644
127--- a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html
128+++ b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html
129@@ -153,3 +153,9 @@
130 <img src="{{ url_for('static', filename='launchpad.ico') }}" class="icon">
131 Launchpad</a>
132 {%- endmacro %}
133+
134+{% macro nonexistent_package() -%}
135+ <p>
136+ Oops! Looks like this package has no previous results. The package itself may not exist - you can check by clicking the Launchpad icon.
137+ </p>
138+{%- endmacro %}

Subscribers

People subscribed via source and target branches