The error when trying to release a revision that's not a integer is ugly

Bug #1604815 reported by Leo Arias
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
High
Carlo Lobrano

Bug Description

The error returned when I try to release to a revision that's not an integer I get an error that's not formatted for a user.

$ snapcraft release u1test20160920 notanumber edge
{'revision': ['This field must be an integer.']}

Tags: bitesize
Leo Arias (elopio)
tags: added: bitesize
Revision history for this message
Kyle Fazzari (kyrofa) wrote :

Yeah, that comes from the store:

"POST /dev/api/snap-release/ HTTP/1.1" 400 None
Traceback (most recent call last):
  File "/home/kyrofa/src/snapcraft/bin/snapcraft", line 31, in <module>
    snapcraft.main.main()
  File "/home/kyrofa/src/snapcraft/snapcraft/main.py", line 244, in main
    return run(args, project_options)
  File "/home/kyrofa/src/snapcraft/snapcraft/main.py", line 288, in run
    _run_store_command(args)
  File "/home/kyrofa/src/snapcraft/snapcraft/main.py", line 352, in _run_store_command
    args['<snap-name>'], args['<revision>'], [args['<channel>']])
  File "/home/kyrofa/src/snapcraft/snapcraft/_store.py", line 559, in release
    channels = store.release(snap_name, revision, release_channels)
  File "/home/kyrofa/src/snapcraft/snapcraft/storeapi/__init__.py", line 213, in release
    self.sca.snap_release, snap_name, revision, channels)
  File "/home/kyrofa/src/snapcraft/snapcraft/storeapi/__init__.py", line 169, in _refresh_if_necessary
    return func(*args, **kwargs)
  File "/home/kyrofa/src/snapcraft/snapcraft/storeapi/__init__.py", line 565, in snap_release
    raise errors.StoreReleaseError(data['name'], response)
snapcraft.storeapi.errors.StoreReleaseError: {'revision': ['This field must be an integer.']}

We need to parse that much better.

Changed in snapcraft:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Kyle Fazzari (kyrofa) wrote :

I'm sure other store-side validation errors will look like this as well, setting to High since they're user-facing.

Revision history for this message
Carlo Lobrano (c-lobrano) wrote :

Hi, I'd like to work on this. Looking at the code, I wonder if the "response" object is expected to always have this format

{'revision': ['This field must be an integer.']}

where could I look to check this?

Thanks in advance

Revision history for this message
Leo Arias (elopio) wrote :

Hello Carlo,

You can find here the docs for the release API:
https://dashboard.snapcraft.io/docs/api/snap.html#id3

It says in there that the error dictionary has the field as the key, and then the reason.

Revision history for this message
Carlo Lobrano (c-lobrano) wrote :

Hi Leo, thanks a lot, I will look into it

Changed in snapcraft:
assignee: nobody → Carlo Lobrano (c-lobrano)
status: Triaged → In Progress
Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Changed in snapcraft:
status: In Progress → Fix Committed
milestone: none → 2.35
Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.