sudo snap install A_COMMERCIAL_SNAP when not logged in gives ugly/misleading 401

Bug #1762552 reported by Daniel Manrique
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snap Store Server

Bug Description

$ sudo snap logout
error: not logged in # Now I'm not logged in
$ sudo snap install the-commercial-snap
error: cannot perform the following tasks:
- Download snap "the-commercial-snap" (16) from channel "stable" (received an unexpected http response code (401) when trying to download

The above message is misleading and ugly. Fixing this should have 2 components:

1- When sending the 401 error code, the store should send a payload indicating the full reason for the unauthorization ("login-required" comes to mind, since we don't even know if the user has purchased the snap without being logged in). This would result in a slightly protracted journey:

sudo snap install foo
"You need to be logged in"
snap login
snap install foo
"You need to buy the snap"
snap buy foo
# web flow
snap install foo

but let's scope this bug to the first step of that flow.

2- On receiving a 401, snapd should check and if the payload indicates login is required, nicely tell that to the user.

So this should also have a snapd task.

Of note, if any of these behaviors are already implemented, feel free to close the task for the corresponding component. IF both seem to be implemented then we have a problem somewhere :)

Tags: api purchasing
William Grant (wgrant)
tags: added: api purchasing
Changed in snapstore:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Daniel Manrique (roadmr) wrote :

Currently the 401 from the store looks like this (no nice error payload):

HTTP/1.1 401 UNAUTHORIZED\r\nContent-Length: 106\r\nContent-Type: application/json\r\nDate: Wed, 19 Dec 2018 21:20:30 GMT\r\nServer: gunicorn/19.7.1\r\nSnap-Store-Version: 10\r\nX-Request-Id: 0AAC4142D0480A325CA101BB5C1AB61E1F83314\r\nX-Vcs-Revision: whatever\r\nX-View-Name: snapdevicegw.webapi_download.snap_download\r\n\r\n

Zygmunt Krynicki (zyga)
Changed in snapd:
status: New → Triaged
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.