Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [bitbake-devel][PATCH] fetch2/crate: guard against empty version list
@ 2026-05-07 14:36 thomas.perrot
  0 siblings, 0 replies; only message in thread
From: thomas.perrot @ 2026-05-07 14:36 UTC (permalink / raw)
  To: bitbake-devel; +Cc: thomas.petazzoni, Thomas Perrot

From: Thomas Perrot <thomas.perrot@bootlin.com>

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 <thomas.perrot@bootlin.com>
---
 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 d84bae0bcd1e..eb1fd5719e8c 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 ("", "")
-- 
2.54.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-07 14:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 14:36 [bitbake-devel][PATCH] fetch2/crate: guard against empty version list thomas.perrot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox