Errors when setting default tracks

This is something I have already discussed on IRC with @facundobatista, just leaving it here so it doesn’t get lost in channel traffic.

It seems the error message for when no tracks exist (other that the default latest) or the track name is typoed produces the same error message:

sergiusens@gotham:~/projects/snapcore/snapcraft$ surl -a staging-package_update -d '{"default_track": "foo"}' | jq .
  "error_list": [
      "code": "invalid-choice",
      "message": "Select a valid choice. That choice is not one of the available choices.",
      "extra": {
        "value": "foo",
        "field": "default_track"

It would be ideal if we could have two different errors for this, maybe:

  • code: no-tracks
  • code: invalid-track (invalid-choice is fine), an attribute in extra and message could list what the valid tracks are.

I don’t think it makes sense to say there are no tracks, since there’s always default and latest available. I agree that the error could hint at valid tracks, but it can’t list all of them (since the list may be arbitrarily large).