snapcraft export-login doesn't provide meaningful error messages when an argument is wrong

Bug #1843404 reported by Johan Lorenzo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Triaged
Medium
Sergio Schvezov

Bug Description

Steps to reproduce:
1. Run

```
expiry_date='2020-09-10T00:00:00'
acls='package_push,package_release,package_access'
snap_name='firefox'
snapcraft export-login --channels=esr --snaps="snap_name" --acls="$acls" --expires="$esr_macaroon_file
```
(Note there's a bug in the last command, "snap_name" instead of "$snap_name".

2. Fill the right credentials.

Expected results: A meaningful error message like: "Server reported 'snap_name' is not a valid snap".

Actual results: Just this error message is provided: "Authentication error: Failed to get macaroon".

Context: I made this mistake after 2 successful macaroon exports. The lack of information lead me to think there was a bug around custom tracks. "ESR" was created in https://forum.snapcraft.io/t/firefox-please-create-the-track-esr/5006. I ended up filing a bug against the server: https://bugs.launchpad.net/firefox/+bug/1843275.

Kudos to Daniel Manrique who gave me a simple way to debug what's happening. Although, I think error messages should provide more info by default.

Revision history for this message
Daniel Manrique (roadmr) wrote :

As seen in the other bug, snapcraft code basically gives a generic "Failed to get macaroon" message if the store responds with a not-OK http status (4xx and 5xx pretty much):

if response.ok:
            return response.json()["macaroon"]
        else:
            raise errors.StoreAuthenticationError("Failed to get macaroon", response)

Revision history for this message
Daniel Manrique (roadmr) wrote :

(Hit enter too quickly, sorry).

Anyway, if snapcraft were to look at the actual payload, https://dashboard.snapcraft.io/dev/api/acl/ will typically send something detailed, such as this:

{
  "type": "devportal:v1:resource-not-found",
  "status": 404,
  "error_list": [
    {
      "message": "Snap not found for the given snap name 'shello-roadmr-1'",
      "code": "resource-not-found"
    }
  ],
  "detail": "Snap not found for the given snap name 'shello-roadmr-1'",
  "title": "Snap not found for the given snap name 'shello-roadmr-1'",
  "code": "resource-not-found"
}

An example can be seen by doing export-login with a non-existent snap name:

SNAPCRAFT_ENABLE_DEVELOPER_DEBUG=yes snapcraft export-login --channels=beta --snaps="this-is-not-a-valid-snap-name-hehehe" --expires="2019-01-01" --acls='package_push,package_release,package_access' /tmp/mac2

The exception, as we've discussed a few times in the past, are some 500 errors which aren't generated by the application server (e.g. the dreaded 503 no server available or 502 timeout) and thus aren't guaranteed to have a json error payload.

Changed in snapcraft:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Sergio Schvezov (sergiusens)
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.