Warn about leading "0" (octal) in snap.yaml?

Bug #1640523 reported by Ondrej Kubik
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Fix Released
High
Barry Warsaw
snapd
Triaged
Medium
Unassigned
snapd (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

USB vip and pid parsing in gadget snap interface definition is very sensitive to the value.
example from snap.yaml
usb-vendor: 0658
this value will make parser fail

Barry Warsaw (barry)
Changed in ubuntu-image:
milestone: none → 0.12
importance: Undecided → High
status: New → Triaged
Barry Warsaw (barry)
Changed in ubuntu-image:
assignee: nobody → Barry Warsaw (barry)
status: Triaged → In Progress
Revision history for this message
Barry Warsaw (barry) wrote :

I'm looking at this again in more detail now and what I don't understand is why this is a bug on ubuntu-image given that u-i doesn't parse the snap.yaml, but instead only the gadget.yaml. And the gadget.yaml doesn't define `usb-vendor` or vip/pid.

However, we already have to special case a few instances where int-like values are parsed into actual integers, from which we have to convert back into strings. What I'd like to do is parse int-like things as strings and then turn the one or two cases back into ints in post-processing. The only values that might naturally be integers are the `size` and `offset` keys, but we already have to post-process them because their values can also have suffixes.

summary: - usb vip and pid parsing fails
+ Parse integer-like YAML values as strings
Barry Warsaw (barry)
Changed in ubuntu-image:
status: In Progress → Fix Committed
Barry Warsaw (barry)
Changed in ubuntu-image:
status: Fix Committed → Fix Released
Barry Warsaw (barry)
Changed in ubuntu-image:
status: Fix Released → New
Revision history for this message
Ondrej Kubik (ondrak) wrote : Re: Parse integer-like YAML values as strings
Revision history for this message
Ondrej Kubik (ondrak) wrote :
Revision history for this message
Ondrej Kubik (ondrak) wrote :
Revision history for this message
Barry Warsaw (barry) wrote :

This isn't a bug in ubuntu-image. The crash is coming from `snap prepare-image` and u-i just forwards that along because there's nothing more it can do. I opened a bugtask for snapd; here's how to reproduce it.

1. wget the model and the gadget snap from w-ondra's attachements
2. ubuntu-image --channel edge -o ../images/ondra.img -d ../models/pi3-ondra.model --extra-snap ../ondra/pi3-ondra_16.04-0.5_armhf.snap

Here's the full traceback so you can see it's coming from snap.

DEBUG:ubuntu-image:-> [ 0] make_temporary_directories
DEBUG:ubuntu-image:-> [ 1] prepare_image
error: attribute "usb-vendor" of slot "zwave-aeon-g5": invalid attribute scalar: 658
ERROR:ubuntu-image:COMMAND FAILED: snap prepare-image --channel=edge --extra-snaps=../ondra/pi3-ondra_16.04-0.5_armhf.snap ../models/pi3-ondra.model /tmp/tmpsbngmcs_/unpack
ERROR:ubuntu-image:Full debug traceback follows
Traceback (most recent call last):
  File "/home/barry/projects/ubuntu/allsnappy/ubuntu-image/ubuntu_image/builder.py", line 128, in prepare_image
    self.args.channel, self.args.extra_snaps)
  File "/home/barry/projects/ubuntu/allsnappy/ubuntu-image/ubuntu_image/helpers.py", line 116, in snap
    run(cmd, stdout=None, stderr=None, env=os.environ)
  File "/home/barry/projects/ubuntu/allsnappy/ubuntu-image/ubuntu_image/helpers.py", line 97, in run
    proc.check_returncode()
  File "/usr/lib/python3.5/subprocess.py", line 659, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['snap', 'prepare-image', '--channel=edge', '--extra-snaps=../ondra/pi3-ondra_16.04-0.5_armhf.snap', '../models/pi3-ondra.model', '/tmp/tmpsbngmcs_/unpack']' returned non-zero exit status 1

Changed in ubuntu-image:
status: New → Fix Released
Revision history for this message
Michael Vogt (mvo) wrote :

In can reproduce this. As a workaround you can remove the leading "0". It looks like for some reason our yaml parser is parsing 0658 as an float64 (which we don't support, only ints are allowed).

Changed in snapd (Ubuntu):
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Michael Vogt (mvo) wrote :

Ok, so - in yaml the leading "0" means octal. And "0658" is of course not a valid octal number. Which looks like we need to warn about those leading "0" to avoid confusion.

Michael Vogt (mvo)
summary: - Parse integer-like YAML values as strings
+ Warn about leading "0" (octal) in snap.yaml?
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Hey Michael.

I've assigned this bug to you since you have indicated that it is in progress. Since the bug was last updated quote a while ago, could you please look at this and decide if it is still an issue, if it is really in progress and if you are willing to work on it?

Changed in snapd:
assignee: nobody → Michael Vogt (mvo)
status: New → In Progress
Michael Vogt (mvo)
Changed in snapd:
assignee: Michael Vogt (mvo) → nobody
status: In Progress → Triaged
Changed in snapd (Ubuntu):
status: In Progress → Triaged
Changed in snapd:
importance: Undecided → Medium
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.