[bitbake][wrynose][2.18][PATCH v2 5/8] fetch2/crate: guard against empty version list
Yoann Congal <[email protected]> Thu, 11 Jun 2026 15:11:27 +0200
| Newsgroups | org.openembedded.lists.bitbake-devel |
|---|---|
| Message-ID | <317cdbef364202ea0a857516d65710c95c96bb1a.1781183212.git.yoann.congal@smile.fr> |
From: Thomas Perrot <[email protected]> Both latest_versionstring() and latest_versionstring_from_index() would raise IndexError on versions[-1] if the fetched index returns no usable versions. Return ("", "") in that case, consistent with what callers expect when no upstream version can be determined. Signed-off-by: Thomas Perrot <[email protected]> Signed-off-by: Mathieu Dubois-Briand <[email protected]> Signed-off-by: Richard Purdie <[email protected]> (cherry picked from commit ffdc2a02693379d7ead0f7b940111340843d49a4) Signed-off-by: Yoann Congal <[email protected]> --- lib/bb/fetch2/crate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bb/fetch2/crate.py b/lib/bb/fetch2/crate.py index d84bae0bc..eb1fd5719 100644 --- a/lib/bb/fetch2/crate.py +++ b/lib/bb/fetch2/crate.py @@ -164,7 +164,7 @@ class Crate(Wget): versions = [(0, i["num"], "") for i in json_data["versions"]] versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp)) - return (versions[-1][1], "") + return (versions[-1][1], "") if versions else ("", "") def latest_versionstring_from_index(self, ud, d): """ @@ -182,4 +182,4 @@ class Crate(Wget): versions.append((0, data["vers"], "")) versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp)) - return (versions[-1][1], "") + return (versions[-1][1], "") if versions else ("", "")