Help needed: cannot use snapcraft login in GitHub action

Hi, I have a GH action to keep the Folding at Home snap updated. It uses a (previously exported) login token to log in and that used to work. However, since last month it’s failing with the following error.

Run echo *** | snapcraft login --with -

Login successful. You now have these capabilities:

snaps:       ['folding-at-home-fcole90']
channels:    ['stable', 'edge', 'candidate', 'beta']
permissions: ['package_access', 'package_manage', 'package_push', 'package_register', 'package_release', 'package_update']
expires:     2022-03-17T22:05:35.869826

Sorry, an error occurred in Snapcraft:
['MmD5jWldYNMNgb2rFFht3FNKGJx1FLLV'] is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['packages']:
    {'oneOf': [{'description': 'A list of packages to restrict the '
                               'macaroon to. Those can be defined in two '
                               'ways: 1- by name: each item in the list '
                               'should be a json dict like `{"name": '
                               '"the-name"}`, or 2- by snap_id: each item '
                               'in the list should be a json dict like '
                               '`{"snap_id": "some-snap-id-1234"}`.',
                'items': {'anyOf': [{'required': ['snap_id']},
                                    {'required': ['name']}],
                          'description': 'Package identifier: a dict with '
                                         'at least name or snap_id keys.',
                          'properties': {'name': {'type': 'string'},
                                         'snap_id': {'type': 'string'}},
                          'type': 'object'},
                'minItems': 1,
                'type': 'array',
                'uniqueItems': True},
               {'type': 'null'}]}

On instance['packages']:
    ['MmD5jWldYNMNgb2rFFht3FNKGJx1FLLV']
Traceback (most recent call last):
  File "/snap/snapcraft/6512/bin/snapcraft", line 33, in <module>
    sys.exit(load_entry_point('snapcraft==4.8', 'console_scripts', 'snapcraft')())
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/snapcraft/cli/store.py", line 840, in whoami
    account = StoreClientCLI().whoami().account
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/snapcraft/storeapi/_store_client.py", line 97, in whoami
    return self.dashboard.whoami()
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/snapcraft/storeapi/_dashboard_api.py", line 369, in whoami
    return whoami.WhoAmI.unmarshal(response.json())
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/snapcraft/storeapi/v2/whoami.py", line 70, in unmarshal
    jsonschema.validate(payload, WHOAMI_JSONSCHEMA)
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/jsonschema/validators.py", line 478, in validate
    cls(schema, *args, **kwargs).validate(instance)
  File "/snap/snapcraft/6512/lib/python3.6/site-packages/jsonschema/validators.py", line 123, in validate
    raise error
jsonschema.exceptions.ValidationError: ['MmD5jWldYNMNgb2rFFht3FNKGJx1FLLV'] is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['packages']:
    {'oneOf': [{'description': 'A list of packages to restrict the '
                               'macaroon to. Those can be defined in two '
                               'ways: 1- by name: each item in the list '
                               'should be a json dict like `{"name": '
                               '"the-name"}`, or 2- by snap_id: each item '
                               'in the list should be a json dict like '
                               '`{"snap_id": "some-snap-id-1234"}`.',
                'items': {'anyOf': [{'required': ['snap_id']},
                                    {'required': ['name']}],
                          'description': 'Package identifier: a dict with '
                                         'at least name or snap_id keys.',
                          'properties': {'name': {'type': 'string'},
                                         'snap_id': {'type': 'string'}},
                          'type': 'object'},
                'minItems': 1,
                'type': 'array',
                'uniqueItems': True},
               {'type': 'null'}]}

On instance['packages']:
    ['MmD5jWldYNMNgb2rFFht3FNKGJx1FLLV']
You can find the traceback in file '/tmp/tmpai0u4zyd/trace.txt'.
Error: Process completed with exit code 1.

Is it a bug or am I doing something wrong?

I submitted a bug report some time ago but got no feedback so far. I use this action to auto rebuild the package upon a CVE is discovered, so now, with this bug, nothing gets automatically released anymore.

The call to “snapcraft whoami” is not returning correctly for one reason or the other. How reproduceable is this?

1 Like

This error i happenening at every attempt. Can you recommend me any test to try? :blush:

You can remove the whoami call from your workflow or change it to something like:

snapcraft whoami || echo "Cannot determine who I am."

The fix for this is scheduled for 4.8.3 on Snapcraft's 21.10 Roadmap, the origin of the issue is that the jsonschema was incorrectly documented.

2 Likes

Thanks a lot :grinning: I had actually misunderstood you in the previous message :sweat_smile: As I was very convinced the error was within the login call, when you mentioned the snapcraft whoami I believed you were referring to some internal mechanic of the login system, rather than my following command :sweat_smile:

Again, thanks a lot for your support and for taking care of this :blush:

In the roadmap, for this issue, you can also mention LP: #1929674, besides (or instead of) this post, if you think that’s worth :blush:

FWIW, this is on candidate channel if you want to try it out and see if it solves your issue (Call for testing: Snapcraft 4.8.3)

1 Like