[Solved] UBUS call system upgrade fails

Trying to execute:
ubus call system sysupgrade "{\"prefix\": \"/tmp/root\",\"path\": \"/tmp/sysupgrade.tar\",\"command\": \". /lib/functions.sh; include /lib/upgrade; do_upgrade_stage2\"}"
just returns
Command failed: Unknown error

Package: procd
Version: 2017-08-22-54b46a35-1
Depends: libc, ubusd, ubus, libjson-script, ubox, libubox, libubus
Status: install user installed
Section: base
Architecture: mips64_octeon
Size: 47225
Filename: procd_2017-08-22-54b46a35-1_mips64_octeon.ipk
Description: OpenWrt system process manager
Installed-Time: 1504467288

Package: ubus
Version: 2017-02-18-34c6e818-1
Depends: libc, libubus, libblobmsg-json, ubusd
Status: install user installed
Section: base
Architecture: mips64_octeon
Size: 6505
Filename: ubus_2017-02-18-34c6e818-1_mips64_octeon.ipk
Description: OpenWrt RPC client utility
Installed-Time: 1504467288

How can i troubleshoot this properly ?

Edit: Seems to be a bad compilation on the previous firmware.
I flashed the new image manually and now it works properly.