thin-edge/thin-edge.io

software_update should not attempt to download an empty url

Closed this issue · 1 comments

Is your feature improvement request related to a problem? Please describe.

Sending a local thin-edge.io software_update command with an empty url field results in the command failing due to a download error, as the empty url value is attempted to be downloaded.

For example, the following command will install jq using the apt sm-plugin:

tedge mqtt pub -r te/device/main///cmd/software_update/local-1234 '{
    "status": "init",
    "updateList": [
        {
            "type": "apt",
            "modules": [
                {
                    "name": "jq",
                    "version": "latest",
                    "url": "",
                    "action": "install"
                }
            ]
        }
    ]
}
'

The command will fail at the download part as shown below in the related log file output of the command:

# cat /var/log/tedge/agent/software-update-2024-05-03T06:25:28.145160512Z.log
----- $ /usr/bin/sudo "/etc/tedge/sm-plugins/apt" "prepare"
exit status: 0

stdout <<EOF
Executing command: "apt-get" "--quiet" "--yes" "update"
Hit:1 http://deb.debian.org/debian bookworm InRelease
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
Fetched 55.4 kB in 0s (317 kB/s)
Reading package lists...
EOF

stderr <<EOF
EOF
----- $ Downloading:  to /tmp/jq_latest 
error: DownloadError error: "builder error: relative URL without a base" for ""

Caused by: relative URL without a base
----- $ /usr/bin/sudo "/etc/tedge/sm-plugins/apt" "finalize"
exit status: 0

stdout <<EOF
Executing command: "apt-get" "--quiet" "--yes" "autoremove"
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
EOF

stderr <<EOF
EOF

Describe the solution you'd like

Ignore empty url fields and don't attempt to download the file. e.g. treat an empty url field exactly the same as when the field is not present.

Describe alternatives you've considered

Additional context

Resolved by #2905 as described in this ticket.

When empty url is provided in local command, it is removed and sm-plugin proceeds as when the field is not present.

System test was created and it can be found here.