Skip to contentSkip to conversation

fetch2/git.py: fix update_mirror_links

PATCH Superseded [email protected] 2 participants 4 messages Dec 30, 2025 – Feb 26

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2/git.py: fix update_mirror_links

From: Chen Qi <[email protected]>

We cannot assume ud has the same fetcher with origud. For example, if we set map git:// to file:// in PREMIRRORS, ud is using local fetcher and origud is using git fetcher. In such case, the ud does have the 'shallow' attribute. And we'll see the following error:

Exception: AttributeError: 'FetchData' object has no attribute 'shallow'

Looking at the logic of this function, I think it's the origud's shallow that should be checked. So the logic becomes: if origud is using shallow and its full shallow tarball does not exist yet, symlink to ensure it exists. This should make more sense.

---
 lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/git.py +1 -1
index 709c692a8..f288afb51 100644
@@ -359,7 +359,7 @@ class Git(FetchMethod):
         super().update_mirror_links(ud, origud)
         # When using shallow mode, add a symlink to the original fullshallow
         # path to ensure a valid symlink even in the `PREMIRRORS` case
-        if ud.shallow and not os.path.exists(origud.fullshallow):
+        if origud.shallow and not os.path.exists(origud.fullshallow):
             self.ensure_symlink(ud.localpath, origud.fullshallow)
 
     def try_premirror(self, ud, d):
Signature · 1 line
2.34.1
#1 lore raw
Quoted 24 lines · Chen Qi via lists.openembedded.org

From: Chen Qi <[email protected]>

We cannot assume ud has the same fetcher with origud. For example, if we set map git:// to file:// in PREMIRRORS, ud is using local fetcher and origud is using git fetcher. In such case, the ud does have the 'shallow' attribute. And we'll see the following error:

Exception: AttributeError: 'FetchData' object has no attribute 'shallow'

Looking at the logic of this function, I think it's the origud's shallow that should be checked. So the logic becomes: if origud is using shallow and its full shallow tarball does not exist yet, symlink to ensure it exists. This should make more sense.

---
 lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/git.py +0 -0
index 709c692a8..f288afb51 100644

lib/bb/fetch2/git.py class Git(FetchMethod): · line 365

Quoted 8 lines
lib/bb/fetch2/git.py +1 -1
@@ -359,7 +359,7 @@ class Git(FetchMethod):
         super().update_mirror_links(ud, origud)
         # When using shallow mode, add a symlink to the original fullshallow
         # path to ensure a valid symlink even in the `PREMIRRORS` case
-        if ud.shallow and not os.path.exists(origud.fullshallow):
+        if origud.shallow and not os.path.exists(origud.fullshallow):
             self.ensure_symlink(ud.localpath, origud.fullshallow)
 
     def try_premirror(self, ud, d):

Hi Qi, thanks for your patience on this one as we work through the backlog.

The only place update_mirror_links is currently called is from try_mirror_url() in lib/bb/fetch2/__init__.py. This is called as origud.method.update_mirror_links(ud, origud), so checking origud.shallow instead of ud.shallow looks correct to me. I think your patch is correct, we'll take another look at it in the next review call and hopefully get it merged.

Best regards,

Signature · 1 line
Paul Barker
#2 lore raw
Quoted 38 lines · Paul Barker
Quoted 24 lines · Chen Qi via lists.openembedded.org

From: Chen Qi <[email protected]>

We cannot assume ud has the same fetcher with origud. For example, if we set map git:// to file:// in PREMIRRORS, ud is using local fetcher and origud is using git fetcher. In such case, the ud does have the 'shallow' attribute. And we'll see the following error:

Exception: AttributeError: 'FetchData' object has no attribute 'shallow'

Looking at the logic of this function, I think it's the origud's shallow that should be checked. So the logic becomes: if origud is using shallow and its full shallow tarball does not exist yet, symlink to ensure it exists. This should make more sense.

---
 lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/git.py +0 -0
index 709c692a8..f288afb51 100644

lib/bb/fetch2/git.py class Git(FetchMethod): · line 365

Quoted 8 lines
lib/bb/fetch2/git.py +1 -1
@@ -359,7 +359,7 @@ class Git(FetchMethod):
         super().update_mirror_links(ud, origud)
         # When using shallow mode, add a symlink to the original fullshallow
         # path to ensure a valid symlink even in the `PREMIRRORS` case
-        if ud.shallow and not os.path.exists(origud.fullshallow):
+        if origud.shallow and not os.path.exists(origud.fullshallow):
             self.ensure_symlink(ud.localpath, origud.fullshallow)
 
     def try_premirror(self, ud, d):

Hi Qi, thanks for your patience on this one as we work through the backlog.

Quoted 6 lines

The only place update_mirror_links is currently called is from try_mirror_url() in lib/bb/fetch2/__init__.py. This is called as origud.method.update_mirror_links(ud, origud), so checking origud.shallow instead of ud.shallow looks correct to me. I think your patch is correct, we'll take another look at it in the next review call and hopefully get it merged.

We are missing some test coverage here as we've never seen the AttributeError on the autobuilder with this patch applied. There was a similiar error seen for v1 of the patch when it was submitted, but that was a different implementation modifying lib/bb/fetch2/__init__.py (the applied version was v3).

We do have a test case that looks relevant in lib/bb/tests/fetch.py:
GitShallowTest.test_shallow_mirrors.

Are you able to look in to this and extend the test coverage if needed?

Best regards,

Signature · 1 line
Paul Barker
author
#3 lore raw

Hi Paul,

Yes. I'll add a test case for it.
The problem was revealed when recipes are using the same SRC_URI + git:// -> file:// PREMIRRORS settings.

Regards,
Qi

-----Original Message-----
From: Paul Barker <[email protected]>
Sent: Thursday, February 19, 2026 10:37 PM
To: Chen, Qi <[email protected]>; [email protected]
Subject: Re: [bitbake-devel][PATCH] fetch2/git.py: fix update_mirror_links

Quoted 38 lines · Paul Barker
Quoted 24 lines · Chen Qi via lists.openembedded.org

From: Chen Qi <[email protected]>

We cannot assume ud has the same fetcher with origud. For example, if we set map git:// to file:// in PREMIRRORS, ud is using local fetcher and origud is using git fetcher. In such case, the ud does have the 'shallow' attribute. And we'll see the following error:

Exception: AttributeError: 'FetchData' object has no attribute 'shallow'

Looking at the logic of this function, I think it's the origud's shallow that should be checked. So the logic becomes: if origud is using shallow and its full shallow tarball does not exist yet, symlink to ensure it exists. This should make more sense.

---
 lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/git.py index renamed from lib/bb/fetch2/git.py +0 -0

709c692a8..f288afb51 100644

lib/bb/fetch2/git.py class Git(FetchMethod): · line 365

Quoted 8 lines
lib/bb/fetch2/git.py +1 -1
@@ -359,7 +359,7 @@ class Git(FetchMethod):
         super().update_mirror_links(ud, origud)
         # When using shallow mode, add a symlink to the original fullshallow
         # path to ensure a valid symlink even in the `PREMIRRORS` case
-        if ud.shallow and not os.path.exists(origud.fullshallow):
+        if origud.shallow and not os.path.exists(origud.fullshallow):
             self.ensure_symlink(ud.localpath, origud.fullshallow)
 
     def try_premirror(self, ud, d):

Hi Qi, thanks for your patience on this one as we work through the backlog.

Quoted 6 lines

The only place update_mirror_links is currently called is from try_mirror_url() in lib/bb/fetch2/__init__.py. This is called as origud.method.update_mirror_links(ud, origud), so checking origud.shallow instead of ud.shallow looks correct to me. I think your patch is correct, we'll take another look at it in the next review call and hopefully get it merged.

We are missing some test coverage here as we've never seen the AttributeError on the autobuilder with this patch applied. There was a similiar error seen for v1 of the patch when it was submitted, but that was a different implementation modifying lib/bb/fetch2/__init__.py (the applied version was v3).

We do have a test case that looks relevant in lib/bb/tests/fetch.py:
GitShallowTest.test_shallow_mirrors.

Are you able to look in to this and extend the test coverage if needed?

Best regards,

--
Paul Barker