Passing --store has weird syntax/requirements and user-facing error is not informative
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
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-look-correct
Registering does-this-look-correct.
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_ENABLE_DEVELOPER_DEBUG=yes --debug don't do the trick).
$ cp /snap/snapcraft/current/bin/snapcraft /tmp/snapcraft
$ sed -i '5iimport http.client\nhttp.client.HTTPConnection.debuglevel = 1\n' /tmp/snapcraft
$ sudo mount -o bind /tmp/snapcraft /snap/snapcraft/current/bin/snapcraft
$ snap run snapcraft register --store gltNg0wohVae8aY4 --yes does-this-look-correct
Registering does-this-look-correct.
send: b'POST /dev/api/register-name/ HTTP/1.1\r\nHost: dashboard.snapcraft.io\r\nUser-Agent: snapcraft/4.3 Ubuntu/18.04 (amd64)\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nAuthorization: Macaroon root=<my root macaroon>, discharge=<my discharge>\r\nContent-Type: application/json\r\nContent-Length: 130\r\n\r\n'
send: b'{"snap_name": "does-this-look-correct", "is_private": false, "series": "16", "store": "\\u200bgltNg0wohVae8aY4"}'
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": "\\u200bgltNg0wohVae8aY4"
Looks like snapcraft is not properly parsing the --store command-line parameter value. Let's try this:
$ snap run snapcraft register --store=gltNg0wohVae8aY4 --yes does-this-look-correct
Registering does-this-look-correct.
send: b'POST /dev/api/register-name/ HTTP/1.1\r\nHost: dashboard.snapcraft.io\r\nUser-Agent: snapcraft/4.3 Ubuntu/18.04 (amd64)\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nAuthorization: Macaroon root=<root>, discharge=<disch>\r\nContent-Type: application/json\r\nContent-Length: 124\r\n\r\n'
send: b'{"snap_name": "does-this-look-correct", "is_private": false, "series": "16", "store": "gltNg0wohVae8aY4"}'
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-look-correct'.
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.
Evaluation history
No evaluation history available.