Comment 4 for bug 2060173

Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

That code in `def get_vault_snap_version():` is very brittle, I feel.

As @odufourc/@nobuto have pointed out, this is due to a change in behaviour of the response from the snapd socket, and not the charm. It's essentially a regression, but evenly, the charm code is brittle and very reliant on the formatting.

As for a fix: use `.splitlines()` instead of .split('\n'), and find the line that startswith("{") and endswith("}"), which can then be json.loads() - but catch any exceptions at that point. Then pull out the version (also with a trap for exceptions), and return it. Log any exceptions for future breakage.