diff mbox series

layerindexlib: restapi.py: fix unbound variable

Message ID 20260506084605.2345360-1-joaomarcos.costa@bootlin.com
State Accepted, archived
Commit df3295f016a74a1414b8af5adb9f2a3967c365b6
Headers show
Series layerindexlib: restapi.py: fix unbound variable | expand

Commit Message

Joao Marcos Costa May 6, 2026, 8:46 a.m. UTC
If the requested branch(es) is not found, a debugging message is
displayed to list it, so the expected behavior is something like this:

$ bitbake-layers layerindex-fetch meta-firefox
NOTE: Starting bitbake server...
Loading https://layers.openembedded.org/layerindex/api/;branch=wrynose...
ERROR: Remote layer index ['https://layers.openembedded.org/layerindex/'] is empty for branches ['wrynose']

However, the variable currently used is unbound, and the error below
comes up:

File "/src/bitbake/lib/layerindexlib/restapi.py", line 216, in load_index_web
    logger.debug("No valid branches (%s) found at url %s." % (branch, url))
                                                          ^^^^^^
UnboundLocalError: cannot access local variable 'branch' where it is not associated with a value

Replace 'branch' by 'branches' to fix this.

Signed-off-by: João Marcos Costa <joaomarcos.costa@bootlin.com>
---
 lib/layerindexlib/restapi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/layerindexlib/restapi.py b/lib/layerindexlib/restapi.py
index 81d99b02e..65405cb7e 100644
--- a/lib/layerindexlib/restapi.py
+++ b/lib/layerindexlib/restapi.py
@@ -213,7 +213,7 @@  class RestApiPlugin(layerindexlib.plugin.IndexPlugin):
         pindex['branches'] = _get_json_response(index.apilinks['branches'] + filter,
                                                     username=up.username, password=up.password)
         if not pindex['branches']:
-            logger.debug("No valid branches (%s) found at url %s." % (branch, url))
+            logger.debug("No valid branches (%s) found at url %s." % (branches, url))
             return index
         index.add_raw_element("branches", layerindexlib.Branch, pindex['branches'])