Generic error message when registering snap names longer than allowed

Bug #1681545 reported by Celso Providelo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snap Store Server
Fix Released
Undecided
Unassigned
Snapcraft
Fix Released
High
Celso Providelo

Bug Description

The current response from the (staging) Store API does not comply with the existing error pattern (particularly, top-level "code" attribute is empty):

{{{
$ snapcraft staging servers> PYTHONPATH=. ./snapcraft/main.py register name-tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long -d
Starting snapcraft 2.28 from ./snapcraft.
Registering name-tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long.
Starting new HTTPS connection (1): myapps.developer.staging.ubuntu.com
"POST /dev/api/register-name/ HTTP/1.1" 400 None
==============================
{'detail': 'Submitted data is not valid.', 'title': 'Invalid request.', 'invalid_params': [{'code': '', 'reason': 'The name name-tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long should not be longer than 40 characters.', 'name': 'snap_name'}], 'status': 400, 'error_list': [{'code': '', 'extra': {'name': 'snap_name'}, 'message': 'The name name-tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-long should not be longer than 40 characters.'}], 'type': 'devportal:v1:request-invalid'}
==============================
Traceback (most recent call last):
  File "./snapcraft/main.py", line 381, in <module>
    main() # pragma: no cover
  File "./snapcraft/main.py", line 253, in main
    return run(args, project_options)
  File "./snapcraft/main.py", line 297, in run
    _run_store_command(args)
  File "./snapcraft/main.py", line 347, in _run_store_command
    snapcraft.register(args['<snap-name>'], args['--private'])
  File "/home/cprov/Canonical/snappy/snapcraft/snapcraft/_store.py", line 327, in register
    store.register(snap_name, is_private)
  File "/home/cprov/Canonical/snappy/snapcraft/snapcraft/storeapi/__init__.py", line 200, in register
    self.sca.register, snap_name, is_private, constants.DEFAULT_SERIES)
  File "/home/cprov/Canonical/snappy/snapcraft/snapcraft/storeapi/__init__.py", line 183, in _refresh_if_necessary
    return func(*args, **kwargs)
  File "/home/cprov/Canonical/snappy/snapcraft/snapcraft/storeapi/__init__.py", line 535, in register
    raise errors.StoreRegistrationError(snap_name, response)
snapcraft.storeapi.errors.StoreRegistrationError: Registration failed.
}}}

Obs: error response printed with locally patched snapcraft.

Celso Providelo (cprov)
Changed in snapstore:
status: New → Confirmed
Revision history for this message
Celso Providelo (cprov) wrote :
Changed in snapcraft:
milestone: none → 2.29
status: New → Fix Committed
assignee: nobody → Celso Providelo (cprov)
importance: Undecided → High
Changed in snapcraft:
status: Fix Committed → Fix Released
Revision history for this message
Facundo Batista (facundo) wrote :

Confirmed that SCA now returns the 'code' field not empty:

{'detail': 'Submitted data is not valid.',
 'error_list': [{'code': 'invalid',
                 'extra': {'name': 'snap_name'},
                 'message': 'The name '
                            'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj '
                            'should not be longer than 40 characters.'}],
 'invalid_params': [{'code': 'invalid',
                     'name': 'snap_name',
                     'reason': 'The name '
                               'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj '
                               'should not be longer than 40 characters.'}],
 'status': 400,
 'title': 'Invalid request.',
 'type': 'devportal:v1:request-invalid'}

Changed in snapstore:
status: Confirmed → Fix Released
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.