Passing --store has weird syntax/requirements and user-facing error is not informative
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snapcraft |
Incomplete
|
Medium
|
Sergio Schvezov |
Bug Description
Trying to register a snap on a brand store for which I am a publisher (I have obfuscated the store ID and snap names).
$ snap run snapcraft register --store gltNg0wohVae8aY4 --yes does-this-
Registering does-this-
Registration failed.
Let's look at what the HTTP dialog shows (macaroon elided). First problem: this requires hacking snapcraft as there doesn't seem to be a switch to enable this verbose debugging (SNAPCRAFT_
$ cp /snap/snapcraft
$ sed -i '5iimport http.client\
$ sudo mount -o bind /tmp/snapcraft /snap/snapcraft
$ snap run snapcraft register --store gltNg0wohVae8aY4 --yes does-this-
Registering does-this-
send: b'POST /dev/api/
send: b'{"snap_name": "does-this-
reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Date: Thu, 08 Oct 2020 13:13:31 GMT
header: Server: gunicorn/19.7.0
header: Content-Type: application/json
<boring headers>
header: Connection: close
header: Transfer-Encoding: chunked
Registration failed.
Second problem: Snapcraft's response on a 400 reply from the store is too terse to be useful.
OK, so looking at the post payload, the store name is borked:
"store": "\\u200bgltNg0w
Looks like snapcraft is not properly parsing the --store command-line parameter value. Let's try this:
$ snap run snapcraft register --store=
Registering does-this-
send: b'POST /dev/api/
send: b'{"snap_name": "does-this-
reply: 'HTTP/1.1 201 Created\r\n'
header: Date: Thu, 08 Oct 2020 13:14:35 GMT
header: Content-Language: en
header: Content-Type: application/json
header: X-VCS-Revision: 8ee7d2f
< A bunch of boring headers elided>
Congrats! You are now the publisher of 'does-this-
This is the third issue. It's workaroundable by using --store=, we can use that in the meanwhile but it would be great if snapcraft would properly parse command-line options.
I realize in hindsight this is an omnibug. Let me know if you'd prefer I file all 3 issues separately, I can gladly do it.
Changed in snapcraft: | |
importance: | Undecided → Critical |
assignee: | nobody → Sergio Schvezov (sergiusens) |
status: | New → Triaged |
OK, so there is a difference between
snap run snapcraft register --store gltNg0wohVae8aY4 --yes does-this- look-correct
and
snap run snapcraft register --store gltNg0wohVae8aY4 --yes does-this- look-correct
(copy paste each and see the results).
What terminal/shell is being used to issue the commands?
Was this a copy paste from some document?
We can strip this, but maybe this is exactly what you want. look-correct' on store 'gltNg0wohVae8a Y4'." to make this more obvious (and would be catched early if not using --yes)
I can add a "Registering 'does-this-