cannot unmarshal state entry for "timings"

Bug #1843683 reported by Zygmunt Krynicki on 2019-09-12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Paweł Stołowski

Bug Description

While reviewing test failures on master I ran across this error:

error: cannot get timings of change 6: could not get timings data from the
       state: internal error: could not unmarshal state entry "timings": json:
       cannot unmarshal number 4.39e+08 into Go struct field
       TimingJSON.duration of type time.Duration

This was on google:ubuntu-14.04-64:tests/main/snap-debug-timings

Changed in snapd:
assignee: nobody → Paweł Stołowski (stolowski)
importance: Undecided → High
Changed in snapd:
status: Confirmed → In Progress
Paweł Stołowski (stolowski) wrote :

Very interesting and bizzare problem. I couldn't reproduce it by running this spread test a 100 of times. The only way to reproduce it programatically in a unit test was to hand-craft state JSON to have such notation for the duration field. Injecting such value via mocked duration helper (even with saving and the restoring state) didn't reproduce it as for some reason json marshaller simply decided to encode it as 439000000. The fact that we hit this randomly means that the encoding is not fully deterministic and sometimes may use scientific notation.

Now, if such value is encountered when unmarshalling, the only way to succesfully unmarshall it to predefined structs is to use floats internally (float64). Decoding with UseNumber flag (e.g. with our DecodeWithNumber() that does that) doesn't help. While changing time.Duration (int64 really) to float64 for the duration field can be made in a backwards-compatible way, I fear the same can happen to doing/undoing fields which also use time.Duration, and that makes the scope of a potential fix bigger.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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